• 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: Sanity Check
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sanity Check


  • Subject: Re: Sanity Check
  • From: email@hidden
  • Date: Thu, 8 Jul 2010 11:16:46 -0600


On Jul 8, 2010, at 10:30 AM, John Johnson wrote:

I have taken all advice and the code now looks like below which cleans up the pointed out controller leak and does not store [self window]:

There still seems to be some problems with your code...

- (IBAction)sewing:(id)sender	{

[[[SewingController alloc] initWithWindowNibName:@"Sewing and Color" andBFileName:&mBFilename] release];
}

The controller is retained in the init method and released when the window closes so this release is to balance the alloc ... in the object where the controller is instanced I do not need a reference to it, I just need to get a window displayed.

You allocate and immediately release the controller here... not quite sure what you're trying to do here, but that basically means you don't have a controller object, and your window will not stay onscreen. Have you actually tested this code?

- (id) initWithWindowNibName:(NSString*)windowNibName andBFileName: (BFilename*)bfilename
{
self = [super initWithWindowNibName:windowNibName];
if (self != nil)
{
[self retain];
m_design = [[self window] contentView];


		[[self window] setDelegate:self];
	}
	return self;
}

Once again, no point in hanging on to the content view and storing it in an ivar, because just like the window, it's easily accessible from -window -contentView. Unless it's a custom view, but I do not see a cast here... Also, do you have a reason for retaining self?

just for easier coding as there is code I haven't shown (proprietary issue) that uses ivars in the content view.
self is retained because it is released where the allc/init call was made




- (void)windowWillClose:(NSNotification *)notification {

	if(m_design->m_dirtyDesign)
		NSLog(@"dirty message");
	else
		NSLog(@"clean, no message");
	[self release];
}

This -release is interesting as well.
so now release it , I am done with it

_______________________________________________

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: 
 >Sanity Check (From: email@hidden)
 >Re: Sanity Check (From: Mike Abdullah <email@hidden>)
 >Re: Sanity Check (From: email@hidden)
 >Re: Sanity Check (From: Sherm Pendley <email@hidden>)
 >Re: Sanity Check (From: email@hidden)
 >Re: Sanity Check (From: John Johnson <email@hidden>)

  • Prev by Date: Re: Programmatically highlighting an NSMenuItem
  • Next by Date: Re: Sanity Check
  • Previous by thread: Re: Sanity Check
  • Next by thread: Re: Sanity Check
  • Index(es):
    • Date
    • Thread