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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:05:39+00:00 2026-06-10T19:05:39+00:00

Got 3 Entities in my CoreData Models Formations with a sections relationship to a

  • 0

Got 3 Entities in my CoreData Models

Formations with a sections relationship to a Sections entity and chapters relationship with a Chapters entity.

So A Formation contains 1 or n sections containing 1 or n chapters

In my section Entity, there is a sortNB attribute (a kind of id), so I would like to sort my sections in my request.

I tried to do :

NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Formations" inManagedObjectContext:_managedObjectContext];
[request setEntity:entity];


NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"sections.sortNB" ascending:YES];
[request setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObjects:@"sections", nil]];
[request setSortDescriptors:[NSArray arrayWithObject:sort]];


NSArray *forms = [[_managedObjectContext executeFetchRequest:request error:nil]mutableCopy];

But got an error :

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'to-many key not allowed here'

How can I proceed ?

I would like to insert same kind of number in my Chapters entity to sort it too, but first, let’s resolve it for Sections :p

Thanks

  • 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-10T19:05:40+00:00Added an answer on June 10, 2026 at 7:05 pm

    Ok so I sort my objects not in my request but after using

    NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"sortNB" ascending:YES]];
    
    NSArray *sortedRecipes = [[[formation sections] allObjects] sortedArrayUsingDescriptors:sortDescriptors];
    

    And it works.

    Thanks for your help.

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

Sidebar

Related Questions

i got 2 entities, Student and Phone, and a relationship one-to-many between them. @Entity
I've got two entities with a one-to-many relationship between them. The entity that holds
I've got 2 entities in JPA: Entry and Comment. Entry contains two collections of
So I've got some data. There are entities. Entities have an arbitrary number of
i've got following example xml: <entity id=1> <name>computer</name> <type>category</type> <entities> <entity id=2> <name>mac</name> <type>category</type>
i use CoreData to store datas, and i have got some entities. how can
So I got entities Level and Tile. Level has a to-many relationship with Tile.
I've got two entities in the entity framework. Now I want to seperate them
I'm working in Hibernate. I got 3 entities, that's the relationship among them: User
I've got a managedObjectContext with 2 entities, each of which contains multiple entries. Objects

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.