I have a core data entity named “Folder”. Each “Folder” has a 1-to-many relationship with the entity “File”, and each file contains the field “filename”.
What is a succinct way of producing an array of all of the filenames for a given folder?
I expected it to be something like:
NSManagedObject* folder = [self getSomeFolder];
NSArray* files = [folder valueForKey:@"files.@unionOfSet.filename"];
… but i’ve been having no luck getting it to go, and Apple’s set operations guide has got me stumped.
Your solution is mostly correct, but you need to use
-valueForKeyPath:instead of-valueForKey:.-valueForKey:is optimized for keys that do not contain multiple elements (separated by.).