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

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can write an HttpModule like this: /// <summary> ///… May 11, 2026 at 11:38 pm
  • Editorial Team
    Editorial Team added an answer Do this instead: public enum MyKeys { Key1, Key2, Key3… May 11, 2026 at 11:38 pm
  • Editorial Team
    Editorial Team added an answer A rule would be considered: p {…} A selector in… May 11, 2026 at 11:38 pm

Related Questions

In my Core Data model, I've got a relationship called listItems which links to
This problem has been kicking my butt for a few days now. I have
In my Core Data managed object model, I have an entity Foo with a
I am using Core Data programmatically (i.e. not using .xcdatamodel data model files) in
I'm working on porting some ancient code (10.2 era) from NSCoding/plist based archiving to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.