【发布时间】:2015-03-04 20:22:50
【问题描述】:
在读取核心数据时,我需要同时获取属性名称和属性值,有什么简单的方法吗?
我一直在尝试将我的对象模型中的第一个元素作为字典检索,但这给了我一个错误提示:
致命错误:NSArray 元素无法匹配 Swift Array 元素 输入
我的代码如下所示:
let appDel:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let context:NSManagedObjectContext = appDel.managedObjectContext!
let fetchReq = NSFetchRequest(entityName: "ActiveIndexes")
fetchReq.resultType = NSFetchRequestResultType.DictionaryResultType
receivedList = context.executeFetchRequest(fetchReq, error: nil) as! [ActiveIndexes]
println(receivedList[0])
任何建议将不胜感激。
【问题讨论】:
-
在我看来就像 stackoverflow.com/questions/28131227/… 的副本 ...
标签: ios swift core-data dictionary