NSPredicate always gives back the same data

Posted by Stef Geelen on Stack Overflow See other posts from Stack Overflow or by Stef Geelen
Published on 2012-10-15T22:54:35Z Indexed on 2012/10/15 23:01 UTC
Read the original article Hit count: 182

I am trying to work with NSPredicates. But it always give me back the same array. Here you can see my predicate.

NSFetchRequest *request = [[NSFetchRequest alloc] init];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"whichAlbum.album_id == %d", AlbumId];
    [request setEntity:[NSEntityDescription entityForName:@"Picture" inManagedObjectContext:self.genkDatabase.managedObjectContext]];
    [request setPredicate:predicate];

Also when I try it hardcoded. It gives back the same array.

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"whichAlbum.album_id == 5"];

Here you can see my database model.

And here you can see how I put data in my database for entity Picture.

+ (Picture *)pictureWithGenkInfo:(NSDictionary *)genkInfo
          inManagedObjectContext:(NSManagedObjectContext *)context
                     withAlbumId:(int)albumId
                   withPictureId:(int)pictureId;
{

    Picture *picture = nil;

    picture = [NSEntityDescription insertNewObjectForEntityForName:@"Picture"
                                          inManagedObjectContext:context];
    picture.url                     = [genkInfo objectForKey:PICTURES_URL];
    picture.pic_album_id            = [NSNumber numberWithInt:albumId];
    picture.picture_id              = [NSNumber numberWithInt:pictureId];


    return picture;
}

Anybody can help me ?

Kind regards

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about ios