为什么不能将 NSCFNumber(核心数据)转换为 NSArray?
错误:
无法将“__NSCFNumber”(XXXXXXXX)类型的值转换为“NSArray”(XXXXXXXX)。
代码:
//Fetch Settings
func fetchAccounSetting(){
let entityDescription = NSEntityDescription.entityForName("UserSettings", inManagedObjectContext: Context!)
let request = NSFetchRequest()
//let data = UserSettings(entity: entityDescription!, insertIntoManagedObjectContext: Context)
request.entity = entityDescription
var dataObjects: [AnyObject]?
do {
dataObjects = try Context?.executeFetchRequest(request)
} catch let error as NSError {
print(error)
dataObjects = nil
}
for result in dataObjects as! [NSManagedObject] {
let dataSelected = NSArray(array: result.valueForKey("favCategory")! as! NSArray)
print(dataSelected)
}
更新:
我怎样才能收到 Count of dataSelected
?