开发者

Request with CoreData

Here is my problem :

My CoreData model have two entity : Players and Results. The important properties o开发者_JAVA技巧f Players are : - ratingTypePlayer, which is a String. - resultsPlayer which is a Too-Many Relationship with Results as Destination. The Inverse relationship is playerResult.

I wish to obtain an array with all the Results of the Players which ratingTypePlayer is equal to "Toto". I don't find this kind of example.

Thanks a lot


You mean, like a fetch request?

NSManagedObjectContext *context = [[NSApp delegate] managedObjectContext];
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:[NSEntityDescription entityForName:@"Player" inManagedObjectContext:context]];
[request setPredicate:[NSPredicate predicateWithFormat:@"ratingTypePlayer == %@", @"Toto"]];
NSArray *players = [context executeFetchRequest:request error:nil];

If you wanted an array of the "resultsPlayer" relationships, you could do:

NSArray *results = [players valueForKey:@"resultsPlayer"];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜