I have a CoreData entity:
A {
prop1
prop2
}
I am in need of building a simple fetch, for retrieving all prop1 of NSManagedObject that has prop2 of a given value.
This is easily explained with a sql statement.
SELECT A.prop1 WHERE A.prop2=<value>
That’s it, just all the values with no distinct clause. So far, I found that the only way to achieve this is by retrieving all the entities with a NSPredicate:
NSPredicate *allProps = [NSPredicate predicateWithFormat:@"prop1 == %@",prop];
The thing is that I only want an NSArray of prop2 rather than the full set of entities to iterate. I was hoping that NSExpression could give me the ability to accomplish that, but I cannot find a way.
Do you have any suggestion ?
I don’t quite get the last part of your question. I suppose what you want can be acheived by the following code
Of course, you would have to set your sort descriptors and all, but this should do the trick.