I get this error when using setPropertiesToFetch. It's odd because info1 and info2 do exist in my entity.

let fetchRequest = NSFetchRequest()
let entityDescription = NSEntityDescription.entityForName("Table1", inManagedObjectContext: managedObjectContext)
fetchRequest.resultType = .DictionaryResultType
fetchRequest.returnsDistinctResults = true
fetchRequest.propertiesToFetch = ["info1", "info2"]
fetchRequest.includesSubentities = true
fetchRequest.entity = entityDescription
do {
let result = try managedObjectContext.executeFetchRequest(fetchRequest)
print(result)
} catch {
let fetchError = error as NSError
print(fetchError)
}
Without propertiesToFetch line I get this output:
[{
info1 = data1;
info2 = data2;
info3 = data3;
}, {
...
}]
Entity needs to be set before propertiesToFetch can be used.
fetchRequest.entity = entityDescription
fetchRequest.propertiesToFetch = ["info1", "info2"]
fetchRequest.includesSubentities = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With