开发者

Does a Core Data NSSet contain an object with a certain ID?

开发者 https://www.devze.com 2023-04-02 00:39 出处:网络
I have a Core开发者_如何学JAVA Data object that contains an NSSet of other objects (e.g. Library object contains NSSet of Books). What\'s the best way to check if an instance of Library contains a boo

I have a Core开发者_如何学JAVA Data object that contains an NSSet of other objects (e.g. Library object contains NSSet of Books). What's the best way to check if an instance of Library contains a book with a certain bookID?

Is it possible to be done with Key Value coding or do I have to enumerate all books and check them manually?


Yes, you can use KVC for this.

BOOL bookExists = [[set valueForKey:@"bookID"] containsObject:@"myBookID"];
0

精彩评论

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