Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)

2008-10-25 Thread Jerry Krinock
I started wondering: Since 'department' is in fact a managed object and can be fetched, why does MyDocument need it as an instance variable? Answer: It doesn't! I eliminated the declaration NSManagedObject *department ; and also I eliminated the -setDepartment: setter and all invoca

Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)

2008-10-25 Thread Jerry Krinock
On 2008 Oct, 25, at 13:01, Quincey Morris wrote: Well, it's not clear what class your -document getter belongs to, or why you're expecting it to be referenced by code you didn't write. Core Data knows nothing about documents. NSPersistentDocument "merely" wraps document behavior around Cor

Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)

2008-10-25 Thread Quincey Morris
On Oct 25, 2008, at 12:20, Jerry Krinock wrote: 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

Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)

2008-10-25 Thread Jerry Krinock
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 - initWith

Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)

2008-10-25 Thread Quincey Morris
On Oct 25, 2008, at 08:15, Jerry Krinock wrote: - (id)initWithType:(NSString *)type error:(NSError **)error { self = [super initWithType:type error:error]; if (self != nil) { NSManagedObjectContext *managedObjectContext = [self managedObjectContext]; [self setDepartment:

NSPersistentDocument: "Settings" (DepartmentsAndEmployees)

2008-10-25 Thread Jerry Krinock
In Apple's DepartmentsAndEmployees Sample Code project, the document (MyDocument) has this instance variable: NSManagedObject* department ; I view this 'department' as special "Document Settings Ivar". There is always one and only one of them in each document. As a matter of fact, f