In the NSPersistentDocument tutorial [1] under "Adding a Department
Object", it is shown how to add a Department as an instance
variable of the document class. I pasted the accessor code from
the tutorial at the end. However, I have found that if you open a
saved document, make some changes, and then choose "Revert" from
the "File" menu, the document will not reopen and the following
appears in the run log:
2006-04-20 12:05:15.165 DepartmentAndEmployees[27425] The
NSManagedObject with ID:0x3fb2e0 <x-coredata://D96D3A5A-0375-4FB4-
ADA2-62C148EA7AB8/Employee/p5> has been invalidated.
Thanks for catching this. There are actually two issues here.
Since the document retains the department object, you must make sure
that it is properly released in the case of the document being
reverted. You need to implement a revertToContentsOfURL:ofType:error:
method, as follows:
Note that although technically correct, due to a bug in
NSObjectController the above is still not sufficient. The object
controller maintains a handle to the department object even after a
revert, so you must also set its content to nil. To work around this,
you need to add an outlet to the controller and then connect it in
Interface Builder.
// add outlet as an instance variable in MyDocument.h
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden