Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)
Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)
- Subject: Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)
- From: Jerry Krinock <email@hidden>
- Date: Sat, 25 Oct 2008 12:20:52 -0700
On 2008 Oct, 25, at 9:51, Quincey Morris wrote:
you must force it to be registered (processPendingChanges) and then
you can tell the undo manager to remove it (removeAllActions).
Thank you, Quincey, that makes sense.
I also have a more fundamental question. Why must we override -
initWithError:type: to initialize the 'department' ivar for new
documents? It seems like we're "faking it". Generally, best practice
is to allocate objects on-demand. And since good Cocoa citizens
should be using getters, I propose instead alloc-init-setting it at
the end of the getter -document implementation, after accessing the
ivar and fetching it from the store have failed.
But when I tried that, a newly-created document didn't "work" (user
could not type anything into any fields). NSLogging tells me that my
getter -document is not invoked during initialization and therefore
the -department ivar does not get set.
Apparently, sometime after initializing a new document, Core Data's
internal magic is directly accessing my 'document' ivar under the
table (and finding nil), instead of using the getter. How can I
change my thinking to understand that this is expected behavior I need
to design for?
Jerry
_______________________________________________
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