• 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: Adding NSLog() changes behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding NSLog() changes behavior


  • Subject: Re: Adding NSLog() changes behavior
  • From: Charles Srstka <email@hidden>
  • Date: Tue, 16 Mar 2004 10:52:40 -0600

On Mar 16, 2004, at 8:05 AM, Wade Tregaskis wrote:

It's probably not your problem in this case, but it might be:

- (void)setImage:(NSImage*)newImage {

if ( image ) [image release];
image = [newImage retain];

What if newImage == image? You may have just deallocated it. Your code should read something more like this:

if (image != newImage) {
[newImage retain];
[image release];
image = newImage;

// Do stuff
}

Why all that? Why not just:

- (void)setImage:(NSImage*)newImage {

if ( image ) [image autorelease];
image = [newImage retain];

// Do stuff
}

Charles
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Adding NSLog() changes behavior
      • From: Wade Tregaskis <email@hidden>
References: 
 >Adding NSLog() changes behavior (From: Michael Becker <email@hidden>)

  • Prev by Date: (no subject)
  • Next by Date: Re: New Font Panel ??
  • Previous by thread: Re: Adding NSLog() changes behavior
  • Next by thread: Re: Adding NSLog() changes behavior
  • Index(es):
    • Date
    • Thread