I am working on a simple iOS Swift app and can't find any solution for a small problem with core data. I have to group some data which i fetch out of core data, but it doesn't work.
This is my fetchRequest:
<NSFetchRequest: 0x7f82fbe105e0> (entity: Sets; predicate: ((null)); sortDescriptors: ((
"(sort, ascending, compare:)"
)); type: NSDictionaryResultType; includesPendingChanges: NO; propertiesToFetch: ((
name
)); propertiesToGroupBy: ((
name
)); )
I have sort and added properties to group by. There is also set a result type - DictionaryResultType.
And here is my 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]
- Entity is a string variabel
- groupDescriptors and propertiesToFetch are arrays of String
Ok I found a solution and it's just simple.
generates only NSManagedObject's. If you change the fetch request to
you will receive your data.