• 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: Crash when calling custom methods in custom subclass.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Crash when calling custom methods in custom subclass. (From: Adam Raney <email@hidden>)
 >Re: Crash when calling custom methods in custom subclass. (From: Charilaos Skiadas <email@hidden>)
 >Re: Crash when calling custom methods in custom subclass. (From: Adam Raney <email@hidden>)
 >Re: Crash when calling custom methods in custom subclass. (From: Adam Raney <email@hidden>)

  • Prev by Date: Hiding a control on MacOS10.2
  • Next by Date: Re: Crash when calling custom methods in custom subclass.
  • Previous by thread: Re: Crash when calling custom methods in custom subclass.
  • Next by thread: [Core Data - Newbie] Custom validation method called twice.
  • Index(es):
    • Date
    • Thread