Ios API-Microsoft认知服务界面,如何返回属性

Ios API-Microsoft认知服务界面,如何返回属性,ios,swift,microsoft-cognitive,Ios,Swift,Microsoft Cognitive,在swift中,我正在使用Microsoft认知服务Face API函数detectWithData,并尝试使用调用[AnyObject]的returnFaceAttributes。我需要有关如何进入阵列的帮助 根据我的假设,[“年龄”、“性别”]可以工作,但我收到一个错误,上面写着: 已将无法识别的选择器发送到实例0x7f9b96043df0 使用[MPOFaceAttributeTypeAge,MPOFaceAttributeTypeGender]会给出一个错误: “MPOFaceAttri

在swift中,我正在使用Microsoft认知服务Face API函数
detectWithData
,并尝试使用调用
[AnyObject]的
returnFaceAttributes
。我需要有关如何进入阵列的帮助

根据我的假设,
[“年龄”、“性别”]
可以工作,但我收到一个错误,上面写着:

已将无法识别的选择器发送到实例0x7f9b96043df0

使用
[MPOFaceAttributeTypeAge,MPOFaceAttributeTypeGender]
会给出一个错误:

“MPOFaceAttributeTypeAge”类型的值不符合预期的元素类型“AnyObject”

出于某种原因,在数组中键入“true”会给出age属性,但所有其他属性都显示为nil

我在网上找不到任何使用swift的例子。如果您能给我提供任何建议或给我指出正确的方向,我们将不胜感激

@IBAction func battleBtn(sender: UIButton){
    if !hasChoosenTop || !hasChoosenBottom{
        showErrorAlert()
    } else{
        if let firstImg = topImg.image, let firstImgData = UIImageJPEGRepresentation(firstImg, 0.8), let secondImg = bottomImg.image, let secondImgData = UIImageJPEGRepresentation(secondImg, 0.8){
            FaceService.instance.client.detectWithData(firstImgData, returnFaceId: true, returnFaceLandmarks: false, returnFaceAttributes: [MPOFaceAttributeTypeAge, MPOFaceAttributeTypeGender], completionBlock: { (face: [MPOFace]!, err: NSError!) in
                if err == nil {
                    var topFace: String?
                    topFace = face[0].faceId
                    var top = face[0].attributes.age
                    print("my faceId: \(topFace)")
                    print("my faceId: \(top)")

                }
            })
        }
    }
}

[AnyObject]包含一个Int数组。例如:
[1,4]
返回年龄和微笑。

请将您的代码作为文本,而不是图片,编辑问题