【发布时间】:2015-05-27 05:18:21
【问题描述】:
我正在开发一个简单的 iOS Swift 应用程序,但对于核心数据的小问题找不到任何解决方案。我必须对从核心数据中提取的一些数据进行分组,但它不起作用。
这是我的 fetchRequest:
<NSFetchRequest: 0x7f82fbe105e0> (entity: Sets; predicate: ((null)); sortDescriptors: ((
"(sort, ascending, compare:)"
)); type: NSDictionaryResultType; includesPendingChanges: NO; propertiesToFetch: ((
name
)); propertiesToGroupBy: ((
name
)); )
我有排序和添加属性来分组。还有一个结果类型——DictionaryResultType。
这是我的 FetchRequest:
fetchRequest = NSFetchRequest(entityName:entity)
fetchRequest.propertiesToGroupBy = groupDescriptors
fetchRequest.propertiesToFetch = propertiesToFetch
fetchRequest.resultType = .DictionaryResultType
let fetchedResults = managedContext.executeFetchRequest(fetchRequest as NSFetchRequest, error: &error) as? [NSManagedObject]
- 实体是字符串变量
- groupDescriptors 和 propertiesToFetch 是 String 数组
【问题讨论】:
标签: ios objective-c swift xcode6 nsfetchrequest