开发者

Querying a 'column' in core data

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 g开发者_运维技巧uide 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 .).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜