On Fri, Jul 24, 2009 at 6:01 PM, Jochen Moeller<[email protected]> wrote: > In a long run I tracked it down when myDocument is made the delegate of > NSApplication.
Why would your document be an NSApplication delegate? What happens when you have two documents open -- you can't have two NSApplication delegates. So your short solution is: "stop making your documents the delegate of your application." The reason why you were getting a crash: NSApplication lives for the duration of your application (duh.) It does not retain its delegate, because delegates are not retained according to Cocoa memory management rules (this is because they often retain the thing they're a delegate of). So when you create a document and set it to be the app's delegate, and then close the document, the application is still going to send its delegate messages to whatever pointer it remembers as its delegate. Unless you explicitly say [NSApp setDelegate:nil] in your document's -dealloc implementation, NSApplication is going to have a weak pointer to nowhere, and will crash when sending a message to it. --Kyle Sluder _______________________________________________ Cocoa-dev mailing list ([email protected]) 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 [email protected]
