Re: Sanity Check
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