• 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:19:26 -0600


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

On Thu, Jul 8, 2010 at 8:57 AM, <email@hidden> 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 (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>
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: Kyle Sluder <email@hidden>)

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