I want to thank Fritz, Greg, Quincy and Uli for their help solving this problem. I don't think there is any general solution to this problem, but I wanted to make two remarks that might help others who run into something similar.

(i) It turned out that i did have two different MyDocument objects. The second was being instantiated by MainMenu.xib. I actually checked the other .xib files looking for a MyDocument object, and turned up nothing; but I didn't think to look at MainMenu.xib.

(ii) I tracked down the problem by creating a breakpoint at - [MyDocument init]. This led me to search every .xib looking for an instantiated MyDocument.

I am a bit puzzled about one thing: I did put an NSLog at the beginning of the -init method, with a view to determining when the second MyDocument object was being instantiated. But, the NSLog fired only once. As many have pointed out, the object could be created with an -initWithCoder, so the NSLog would be skipped (presumably this is what happened when the .xib instantiated the object). But if this reasoning is correct, why, then, would -[MyDocument init] as a breakpoint stop the code twice? I mean, it shouldn't stop the code when -initWithcoder is called, right?

Anyway, thanks again for all your help.

On 10-Jun-09, at 11:48 AM, Uli Kusterer wrote:

On 09.06.2009, at 17:48, Greg Guerin wrote:
How do you know -init is only run once?

Are you sure no other init method is run?  Like maybe initWithCoder:?


As a general rule, when you wonder where an object is coming from, it helps to have a look at any and all -init methods the class has. In particular init and initWithCoder:. In addition to that, objects can be created by a call to copy or mutableCopy, so you can get very interesting behaviour if your base class implements NSCopying and you forgot to override that in the subclass and do your own additional work.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/dotto%40csusb.edu

This email sent to do...@csusb.edu

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to