John, I suggest reading: http://www.corbinstreehouse.com/blog/2007/10/instruments-on-leopard-how-to-debug-those-random-crashes-in-your-cocoa-app/
--corbin On Feb 2, 2010, at 11:02 AM, John Nairn wrote: > I copied code from Cocoa documentation to create a custom field editor. It > gets created OK and seems to work, but always crashes when the the window > closes with the message > > Program received signal: “EXC_BAD_ACCESS”. > sharedlibrary apply-load-rules all > > I created the custom editor in the window controller using code from Apple: > > - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject > { > if([anObject isKindOfClass:[NSTextField class]]) > { if(!customEditor) > { customEditor=[[BrowserFieldEditor alloc] init]; > [customEditor setFieldEditor:YES]; > } > return customEditor; > } > return nil; > } > > When the window controller is deallocated, it calls > > [customEditor dealloc]; > > Finally, the entire custom editor, which is NSTextView subclass, is > > @implementation BrowserFieldEditor > > - (id)init > { if(self=[super init]) > { NSLog(@"init field editor"); > } > return self; > } > > - (void)dealloc > { NSLog(@"dealloc field editor"); > [super dealloc]; > } > > @end > > The "init field editor" message appears when created and the "dealloc field > editor" appears just before the crash. If I change the window controller to > not release the custom editor, the crash stops, but the "dealloc field > editor" message never appears (i.e., a memory leak). Also the Apple > documentation explicitly says: > > The custom field editor should be released in an appropriate place, such as > the dealloc method of the window delegate object (if the field editor was > never instantiated, therelease message has no effect and is harmless). > _______________________________________________ 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