Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8690139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:50:25+00:00 2026-06-12T23:50:25+00:00

I am trying to work with NSPredicates. But it always give me back the

  • 0

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"];

My database model is:

enter image description here

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
EDIT

  for (NSDictionary *genkInfo in albums ) {
        albumId++;
        Album *album = [Album albumWithGenkInfo:genkInfo inManagedObjectContext:document.managedObjectContext withAlbumId:albumId];
        for (NSDictionary *genkInfo2 in pictures ) {
            pictureId++;
            Picture *pic = [Picture pictureWithGenkInfo:genkInfo2 inManagedObjectContext:document.managedObjectContext withAlbumId:albumId withPictureId:pictureId];
            [album addPicturesObject:pic]; // this method should be automatically generated
        }
        pictureId = 0;
        // table will automatically update due to NSFetchedResultsController's observing of the NSMOC
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:50:26+00:00Added an answer on June 12, 2026 at 11:50 pm

    Better, assuming the value for AlbumId is some kind of number primitive:

    old style:
    [NSPredicate predicateWithFormat:@"whichAlbum == %@", [NSNumber numberWithInt:AlbumId]];
    modern style: (xcode 4.5)
    [NSPredicate predicateWithFormat:@"whichAlbum == %@", @(albumId)];
    

    As it looks like predicateWithFormat: might only generate proper predicates with %@ and @K in its format strings.

    Best: Assuming you have access to the Album managed object you are trying to match try this:

    [NSPredicate predicateWithFormat:@"whichAlbum == %@", album];
    

    Match to the object, not one of its properties

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to work with array, but it gives me Statement requires expression of integer
Programming Student here...trying to work on a project but I'm stuck. The project is
Im trying to work harder with those constructions but definitelly I dont see them
Trying to work with groupby so that I can group together files that were
I am trying to work out why I can not access the nested function
So I am trying to work through the example here: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/SurfaceViewOverlay.html and on the
Trying to work with ImageField in django. Here are my models class Album(models.Model): title
I am trying to filter an array using a predicate checking for files ending
I´m trying to work with Jzy3D library and paint some charts under openGl. But
I am trying to work with Jquery UI slider where I can have multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.