initWithCoder Confusion
initWithCoder Confusion
- Subject: initWithCoder Confusion
- From: Tom Gray <email@hidden>
- Date: Mon, 15 Sep 2003 16:37:02 -0400
Hello,
I have a simple document based application. My NSDocument subclass
seems to be instantiating two different objects when it comes into
existence following opening of a file. I use O'Reilly's Building Cocoa
Applications "MathDocument" sample code as my sample code.
As in their sample, my NSDocument subclass has an init and an
initWithCoder method. At the completion of the init the memory address
of self is different then the memory address of initWithCoder. I have
two instances of my document. The controller that uses this document
points to the instance created with the init, unfortunately, my data is
in the instance that came into existance with the initWithCoder.
Here is a log where I logged the method and the current memory value of
self:
2003-09-15 16:25:05.694 Crewdog Terminal[2334] init self:
<CDTextEditorDocument: 0x1476c40>
2003-09-15 16:25:05.872 Crewdog Terminal[2334] loadDataRepresentation
self: <CDTextEditorDocument: 0x1476c40>
2003-09-15 16:25:05.873 Crewdog Terminal[2334] initWithCoder self:
<CDTextEditorDocument: 0x12eb90>
2003-09-15 16:25:05.944 Crewdog Terminal[2334] makeWindowControllers
self: <CDTextEditorDocument: 0x1476c40>
2003-09-15 16:25:05.945 Crewdog Terminal[2334] windowNibName self:
<CDTextEditorDocument: 0x1476c40>
The NSDocument subclass init's and is at 0x147, next
loadDataRepresentation is called, still with self at 0x147, then
initWithCoder is called and self has changed to 0x12eb90. After exiting
initWithCoders execution continues with makeWindowControllers and
windowNibName but now self is back to 0x147.
What have I done?
Tom Gray
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.