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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:11:38+00:00 2026-06-09T14:11:38+00:00

I have two objects with a relationship in my Data Model… Person {Name, position,

  • 0

I have two objects with a relationship in my Data Model…

  1. Person {Name, position, Title}
  2. Position {position, PositionSort}

Each of the above have their own class files (subclasses of NSManagedObject). I’m trying to sort by PositionSort above. I can currently sort by Position by using the following code.

NSSortDescriptor *sortDescriptorPosition = [[NSSortDescriptor alloc] initWithKey:@"position" ascending:YES];

I am unsure though how I’m able to access and use the PositionSort. Any ideas? Thanks!

UPDATE: Added full function…

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

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

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

    [fetchRequest setFetchBatchSize:20];

    NSSortDescriptor *sortDescriptorState = [[NSSortDescriptor alloc] initWithKey:@"position.positionSort" ascending:YES];

    NSArray *sortDescriptors = [NSArray arrayWithObjects:sortDescriptorState, nil];

    [fetchRequest setSortDescriptors:sortDescriptors];


    NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"(companyID == %@)", company.companyID];
    [fetchRequest setPredicate:searchPredicate];

    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"position.positionDescription" cacheName:nil];

    aFetchedResultsController.delegate = self;
    self.fetchedResultsController = aFetchedResultsController;

    NSError *error = nil;
    if (![self.fetchedResultsController performFetch:&error]) {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }

    return __fetchedResultsController;
}

With the above code I’m getting the following error at Runtime.

2012-08-12 10:29:45.499 College[269:707] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFString 0xd6bd310> valueForUndefinedKey:]: this class is not key value coding-compliant for the key positionDescription.'
  • 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-09T14:11:39+00:00Added an answer on June 9, 2026 at 2:11 pm

    I’m not sure you want to sort exactly, but the following NSSortDescriptor can be used to sort the Person objects using the PositionSort value.

    NSSortDescriptor *sortDescriptorPosition = [[NSSortDescriptor alloc] initWithKey:@"position.PositionSort" ascending:YES];
    

    perhaps, you looked for this…

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

Sidebar

Related Questions

I have two objects I need to create a relationship between in Core Data.
I have core data model with two entities that have a many-to-many relationship with
I have a basic Core data model like this: Class -Class Name (string) Relationship:
I have two objects of the same class (Model) type. I want to check
Suppose that I have two objects with the same property name that I am
OK so I have two entities in my data model (let's say entityA and
I have the following core data model with two entities: entity item which holds
If I have two Models that have a manytomany relationship with a through model,
I have two persistent stores with objects that use the same model. I would
I have two core data entities, Articles and Favorite . Articles has To-Many relationship

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.