• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Core Data : How force end editing of new object before Undo?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data : How force end editing of new object before Undo?


  • Subject: Core Data : How force end editing of new object before Undo?
  • From: Jerry Krinock <email@hidden>
  • Date: Thu, 01 Dec 2011 05:17:32 -0800

App has an NSTableView; each row represents a managed object in NSPersistentDocument.

• User inserts a new object.
• Object is inserted with -[NSEntityDescription insertNewObjectForEntityForName::].
• New row appears in the table.
• New row's "Name" column field editor becomes first responder, showing "untitled".
• But instead of entering a name, user hits ⌘Z to Undo.
• Core Data deletes new object with -[NSManagedObjectContext deleteObject:].
• Row disappears.
• User hits ⌘W to close the document.

Result:
Cocoa Error 134130 with underlying exception: "Cannot update object that was never inserted".  In error's info, affected object is that new object.

I can fix this problem by overriding my undo manager's -undo and sending the window controller an -endEditing before invoking super.  But this requires a little poking around to get from the undo manager to the window controller, which looks like a kind of layer violation, that is, I'm fighting Cocoa.

What is the correct way to make sure that editing is ended before undoing?

Thank you,

Jerry Krinock

P.S.  In some of Apple's Core Data sample code, I see that they create a mini undo manager for a "New Object" sheet.  I don't have a sheet, just a table view, and only one undo manager for my document.  Wrestling with one undo manager in a Core Data document is enough for me and I am loathe to make more of them.  But should I?

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Core Data : How force end editing of new object before Undo?
      • From: Jerry Krinock <email@hidden>
  • Next by Date: "Unusual" interface, usage of 3d party GUI framework and Mac App Store
  • Next by thread: Re: Core Data : How force end editing of new object before Undo?
  • Index(es):
    • Date
    • Thread