On Jul 8, 2010, at 10:41 AM, Kyle Sluder wrote:

On Thu, Jul 8, 2010 at 8:57 AM,  <k...@highrolls.net> wrote:
- (IBAction)sewing:(id)sender   {

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

This is entirely wrong. Why would you create an object just to
immediately release it? Please review the Cocoa Memory Management
Guide: 
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html

Because I retain it in the init method , I don't need a reference to it where the alloc is called


}



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

This is insanity. Again, please reread the memory management guide.

               m_design = [[self window] contentView];


               [[self window] setDelegate:self];

Why don't you just make these outlets and wire them up in Interface
Builder? And even if you wanted to do this in code for some reason,
the appropriate place to do it would be in -windowDidLoad. Right now
you're loading the window from within the initializer, which is wrong.

Ok, I understand -windowDidLoad is the place for these

       }
       return self;
}

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

       if(m_design->m_dirtyDesign)
               NSLog(@"dirty message");
       else
               NSLog(@"clean, no message");

If you're writing a document-based application, NSDocument does dirty
tracking for you already.

Not document based

       [self release];

Again, read the memory management guide. Perhaps consider investing in
Aaron Hillegass's Cocoa Programming for Mac OS X.

this release balances the retain in the init method seems correct to me

}

--Kyle Sluder


_______________________________________________

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

Reply via email to