StackMob をバックエンドとして使用します。user (type )Event
という関係を持つエンティティがあります。現在、一部のユーザーのすべてのイベントを取得したいと考えています。私のコードは次のようになります:users
NSSet
username
@"someuser"
[self.client getLoggedInUserOnSuccess:^(NSDictionary *result) {
NSString *currentlyLoggedInUser = [result valueForKey:@"username"];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *eventEntity = [NSEntityDescription entityForName:@"Event" inManagedObjectContext:self.managedOjbectContext];
[request setEntity:eventEntity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY users.username = %@", currentlyLoggedInUser];
NSLog(@"predicate: %@", predicate);
[request setPredicate:predicate];
NSLog(@"request: %@", request);
events = [NSArray new];
events = [self.managedOjbectContext executeFetchRequest:request error:nil];
/* this is working...
for (Event *e in events) {
NSLog(@"%@",[e.users filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"username == %@", currentlyLoggedInUser]]);
}
*/
NSLog(@"events: %@", events);
} onFailure:^(NSError *error) {
}];