• 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 09:57:46 -0600

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]:


- (IBAction)sewing:(id)sender {

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




- (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;
}

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

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





On Jul 8, 2010, at 9:03 AM, Sherm Pendley wrote:

On Thu, Jul 8, 2010 at 10:19 AM, <email@hidden> wrote:
his seems weird. Why assign the panel/window to your own ivar when this is
exactly -[NSWindowController window] is designed to do for you?

I was thinking I might need to reference it and rather than call for it just
have it hanging around. Yes, no?

Did you profile (with Shark or Instruments) your code, and did the profiler tell you that calls to -window are taking up a significant amount of your app's time? If not, what you're doing is called "premature optimization," and it's generally considered a bad idea.

sherm--

--
Cocoa programming in Perl:
http://www.camelbones.org


_______________________________________________

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


  • Follow-Ups:
    • Re: Sanity Check
      • From: Kyle Sluder <email@hidden>
    • Re: Sanity Check
      • From: John Johnson <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>)

  • Prev by Date: Re: Programmatically closing a submenu (NSMenu)
  • Next by Date: Re: Sanity Check
  • Previous by thread: Re: Sanity Check
  • Next by thread: Re: Sanity Check
  • Index(es):
    • Date
    • Thread