Re: Crash when calling custom methods in custom subclass.
Re: Crash when calling custom methods in custom subclass.
- Subject: Re: Crash when calling custom methods in custom subclass.
- From: "John C. Randolph" <email@hidden>
- Date: Sat, 30 Jul 2005 15:46:31 -0700
On Jul 30, 2005, at 12:01 PM, Adam Raney wrote:
Also taking your advice, my setters now utilize this format:
- (void) setContent: (NSString *)newContent
{
[_content release];
_content = [newContent copy];
}
Adam, I'm not sure whose advice you're referring to, but the setter
above is a potential crasher. If newContent is the same object
you've already got in _content, then when you release it, it may be
destroyed immediately. If that happens, then [newContent copy] will
crash your app, since you'll be trying to send a -copy message to a
freed object.
Also, you shouldn't use leading underscores in your ivar names.
-jcr
John C. Randolph <email@hidden> (408) 914-0013
Roaming Cocoa Engineer,
Available for your projects at great Expense and Inconvenience.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden