• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Custom Field Editor Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom Field Editor Problem


  • Subject: Re: Custom Field Editor Problem
  • From: Corbin Dunn <email@hidden>
  • Date: Tue, 02 Feb 2010 13:58:40 -0800

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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Custom Field Editor Problem (From: John Nairn <email@hidden>)

  • Prev by Date: Re: Showing a menu after a delay...?
  • Next by Date: Re: Analyzer Questions
  • Previous by thread: Re: Custom Field Editor Problem
  • Next by thread: Core Data - Need an Observer but where and how to implement
  • Index(es):
    • Date
    • Thread