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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:30:46+00:00 2026-05-25T00:30:46+00:00

I have an NSArrayController bound to a property of an NSManagedObject subclass. The subclass

  • 0

I have an NSArrayController bound to a property of an NSManagedObject subclass. The subclass is automatically generated by mogenerator (which creates a set property for the relationship).

The NSArrayController is bound to network.posts where ‘posts’ is a 1-M relationship. Note I am binding to ‘posts’ rather than the ‘postsSet’ mutableSet accessor generated by mogenerator.

The set represents a relationship with another entity. The array controller has a sort descriptor set and, when the window it is associated with opens, data is displayed in the correct sort order.

Then I add a new object by instantiating an entity and then adding it to the relationship.

The NSArrayController is correctly observing this change and the new object appears in arrangedObjects however, after the insert the sort order of arrangedObjects is lost and the records appear in a different order.

I have verified that the sort descriptor is still set correctly. The NSArrayController has autoRearrangeContent=YES. I’ve even tried manually calling -rearrangeObjects after the insert but the sort order remains wrong.

If I close the window and re-open the newly instantiated NSArrayController has the data with the correct sort order again. Until I do another insert.

My experience has been that NSArrayController has automatically kept the correct sort order when objects are added/removed but maybe that was a lucky coincidence?

I can’t find any description of the correct behaviour in the Apple document so I’ve no idea what to expect, what might be going wrong (if anything), or – in either case – what I should do about it.

1) Given a sortDescriptor should NSArrayController be keeping arrangedObjects sorted after objects are inserted/removed from the underlying collection?

2) If so, what might prevent this from happening?

3) And, if not, what is the correct way to keep arrangedObjects sorted?

I’d be grateful for any help. It’s not easy to provide useful source code in this situation since, in principle, there isn’t any. But I’m happy to clarify and answer any follow-up questions.

  • 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-05-25T00:30:47+00:00Added an answer on May 25, 2026 at 12:30 am

    Turn off lazy fetching. Not sure the reason but when the controller is being lazy it doesn’t resort things when they are edited or added.

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

Sidebar

Related Questions

I have an NSTableView bound to an NSArrayController , which is bound to an
I have a NSTreeController which array is bound to a items (custom) property of
I have an NSArrayController whose content is the servers property of my AppDelegate. I
Lets say I have an NSArrayController which contains items each with netCost and netProfit
I have a problem with a bound property of a custom view. The property
I have the following set-up: A Window that has a splitView in which I
I have a NSArrayController bound to a NSTableView. With this I have the typical
I have a managedObjectContext for the main application that has a bound NSArrayController and
I have a NSCollectionView is bound to an NSArrayController that has an NSMutableArray as
Have just started using Visual Studio Professional's built-in unit testing features, which as I

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.