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 7861983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:57:27+00:00 2026-06-02T22:57:27+00:00

My core data is defined as this: user has many events; event has a

  • 0

My core data is defined as this:
user has many events;
event has a single user relationship;

Both user and event are core data entities. The user entity is passed in through a storyboard segue.

I’m trying to configure NSPredicate to populate the detail UITableView for that user with only events for that particular user.

So far I have tried

//does not work
 NSPredicate* onlyThisUserPredicate = [NSPredicate predicateWithFormat:@"user == %@",self.appUser];

//does not work
 NSPredicate* onlyThisUserPredicate = [NSPredicate predicateWithFormat:@"SELF.user == %@",self.appUser];

What is the proper syntax to compare events and only return those that have user object equal to the specified user object?

UPDATE:

I’m trying to be able to add events to the user with this kind of fetched results controller:

-(NSFetchedResultsController*)fetchedResultsController
{
    if (__fetchedResultsController != nil) {
        return __fetchedResultsController;
    }

    // Set up the fetched results controller.
    // Create the fetch request for the entity.
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    // Edit the entity name as appropriate.
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Event" inManagedObjectContext:[Event managedObjectContext]];
    [fetchRequest setEntity:entity];

    // Set the batch size to a suitable number.
    [fetchRequest setFetchBatchSize:20];

//I need to configure this user
    NSPredicate* onlyThisUserPredicate = [NSPredicate predicateWithFormat:@"user = %@",self.appUser];


    // The first sort key must match the section name key path key if present, otherwise the initial dataset would be messed up: rows in incorrect sections

    NSString* firstSortKey = @"createDate";
    NSSortDescriptor *firstSortDescriptor = [[NSSortDescriptor alloc] initWithKey:firstSortKey ascending:YES];
    NSArray *sortDescriptors = [NSArray arrayWithObjects:firstSortDescriptor, nil];

    [fetchRequest setSortDescriptors:sortDescriptors];
    [fetchRequest setPredicate:onlyThisUserPredicate];

    // Edit the section name key path and cache name if appropriate.
    // nil for section name key path means "no sections".
    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:[Event managedObjectContext] sectionNameKeyPath:nil cacheName:@"Events"];
    self.fetchedResultsController = aFetchedResultsController;
    aFetchedResultsController.delegate = self;

    //    [aFetchedResultsController release];
    [sortDescriptors release];
    [fetchRequest release];

    NSError *error = nil;
    if (![__fetchedResultsController performFetch:&error]) {
        /*
         Replace this implementation with code to handle the error appropriately.

         abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 
         */
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        //      abort();
    }


    return __fetchedResultsController;
}

Thank you!

  • 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-02T22:57:28+00:00Added an answer on June 2, 2026 at 10:57 pm

    OK, there are a couple of things that I can think of that might cause this behavior.

    First, have you validated the value of self.appUser within this function? Is it set to what you expect?

    Second, have you made sure your headers are all up to date and included in this file? Sometimes I’ve experienced odd behavior when my headers aren’t up to date with the coredata model.

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

Sidebar

Related Questions

I have a core data model defined as follows: A User has many events.
I'm using core data and I have an entity defined called LogRecord. Elsewhere this
In my core data model I have a Person entity that has a to
I have the following relationship defined in Core Data Person --> Worked <-- Job
I am using Core Data and want a Text Label to display how many
I'm using core data in my app. I have two entities that are related:
I am starting to have a look at Core Data, as many claiming is
I have a fetch request defined within my core data model called RemainingGaneProjections. I
So say I'm getting results from my core data request: (this is example code)
does core data create a sqlite database automatically? if yes, why it's not visible?

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.