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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:48:00+00:00 2026-05-11T15:48:00+00:00

In my Core Data model, I’ve got a relationship called listItems which links to

  • 0

In my Core Data model, I’ve got a relationship called listItems which links to several listItem entities, each with a stringValue attribute. I’ve created a control which is essentially a list of NSTextFields, one for each list item. The control is bound to listItems properly, and I’ve set it up so that pressing the return key creates a new field directly under the currently-edited one and changes the focus to the new field. So, essentially, to add a new item, the user presses Return.

Likewise, if the user ends editing and the currently-edited field is empty, the field is removed (as in, empty fields only appear during ‘edit mode’, so to speak). This works pretty well. Basically, in my listItem NSManagedObject subclass, I do the following:

// Don't allow nil values if (!value && [[self.recipe ingredients] count] > 1) {     for (EAIngredientRef *ingredient in [self.recipe ingredients]) {         if ([[ingredient sortIndex] integerValue] > [[self sortIndex] integerValue]) {             [ingredient setSortIndex:[NSNumber numberWithInteger:([[ingredient sortIndex] integerValue]-1)]];         }     }     [[self managedObjectContext] deleteObject:self];     return; }  // Code to handle if it is a real value 

The problem I am encountering is that each time a row is deleted this way, it registers with the undoManager. Thus, if I edit a row, press Return (which creates a new row), and click away to end editing, the row disappears. However, if I then undo, the empty field reappears. My goal is to have delete operations involving empty fields be ignored by the undoManager.

How would I go about this? I’ve tried using [[[self managedObjectContext] undoManager] disableUndoRegistration] and the associated enableUndoRegistration in several spots (such as -didTurnIntoFault, but I suspect that the undo registration might be happening prior to that method)

  • 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. 2026-05-11T15:48:00+00:00Added an answer on May 11, 2026 at 3:48 pm

    If you dive more deeply into the Core Data docs, you’ll find this tidbit hidden away:

    [[self managedObjectContext] processPendingChanges]; [[[self managedObjectContext] undoManager] disableUndoRegistration]; // Do your work [[self managedObjectContext] processPendingChanges]; [[[self managedObjectContext] undoManager] enableUndoRegistration]; 

    Changes are not registered with the undo manager normally until the end of the event loop, and so were being registered after you’d turned undo registration back on. The above forces it to occur when you want.

    • 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 which includes an entity with a to-many relationship.
I have a Core Data model which has three entities: A, B, and C.
I have a relationship in a Core Data model that feels like it wants
My Core Data model contains an entity, Shape, that has two self-referential relationships, which
My Core Data model looks like this: alt text http://fwdr.org/lg4q The players relationship of
I have a Core Data model in which a Task entity includes an optional
I have a Core Data model setup like so: Blockbuster Entity To-Many relationship to
I have a basic Core data model like this: Class -Class Name (string) Relationship:
I have a core data model with 2 entities: Collection and Image. There's a
Given the following Core Data Model: -> : to-one releationship ->>: to-many relationship Entity

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.