Re: Adding NSLog() changes behavior
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.