iPhone CoreData join

Posted by Ken on Stack Overflow See other posts from Stack Overflow or by Ken
Published on 2010-03-16T21:21:21Z Indexed on 2010/03/17 16:01 UTC
Read the original article Hit count: 701

Filed under:
|
|
|

Hi guys, long time reader, first time poster.

(A link to this schema is located here)

http://www.weeshsoft.com/pix/DatabasePic.jpg

I'm trying to get all LanguageEntries from a database for a given category.categoryName and languageset.languageSetName e.g.

NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init];

    NSEntityDescription *entity = [NSEntityDescription entityForName:@"LanguageEntry" inManagedObjectContext:del.managedObjectContext];
    [fetchRequest setEntity:entity];

NSString* predicateString = [NSString stringWithFormat:@"Category.categoryName = %@ AND LanguageSet.languageSetName = %@", 
                        @"Food", @"English####Spanish"];

fetchRequest.predicate = [NSPredicate predicateWithFormat:predicateString];

NSError *error = nil;
NSArray* objects = [del.managedObjectContext executeFetchRequest:fetchRequest error:&error];

This always returns 0 objects. If I set the predicate string to match on one relationship (e.g. Category.categoryName = Food or languageSet.languageSetName = English####Spanish) it will return data.

This is baffling, can anyone shed some light?

->Ken

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.0

Related posts about core