iOS10以来,我一直面临着这个问题:
无法将类型 '__NSSingleObjectArrayI' 的值转换为 'NSMutableArray'。
以下是我的代码:
manage.POST( url, parameters: params,
constructingBodyWithBlock: { (data: AFMultipartFormData!) in
//Some stuff here
},
success: { (operation: NSURLSessionDataTask?, responseObject: AnyObject?) in
var array : NSMutableArray!
if AppConfig.sharedInstance().OCR == "2"{
let dictionnary = responseObject as! NSDictionary
array = dictionnary["data"]! as! NSMutableArray
}else{
//!!!!CRASH HERE!!!!!
array = responseObject as! NSMutableArray
}
//Some stuff after
}
当我寻找responseObject的值时,在控制台上看到了以下内容:
Printing description of responseObject:
▿ Optional<AnyObject>
▿ Some : 1 elements
- [0] : Test
我怎样从responseObject中提取值"Test"?
非常感谢。