• 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: How far with accessors?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How far with accessors?


  • Subject: Re: How far with accessors?
  • From: Greg Hulands <email@hidden>
  • Date: Thu, 27 May 2004 09:26:16 +1000

I think you will find in the setTheString: method that it will autorelease or release the current string so there would be no problem with this. Just a round about way of doing it.

On 27/05/2004, at 7:58 AM, Jeff Biggus wrote:

On May 26, 2004, at 3:11 PM, Ondra Cada wrote:

The preferred method is

-(void)dealloc {
[self setTheString:nil];
...
}

Perhaps I need to read the whole thread, but I've never seen it suggested that one should simply nil out an object. In general, the preferred way is simply to do a release:

-(void)dealloc {
[theString release];
...
[super dealloc];
}

Directly setting the object to nil should not be the first option. It will not be necessary if there are no memory management holes in your code. It seems like bad form to just set it to nil, though it may not cause any problems (I'm not sure of this either way).

Some developers will write "theString = nil;" after releasing the object, but this is only to protect against memory management mistakes that can happen during development. It's perfectly safe, but it's a band aid which shouldn't need to be there, afaiu.

-Jeff
_______________________________________________
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.
_______________________________________________
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.


References: 
 >Fwd: How far with accessors? (From: Ondra Cada <email@hidden>)
 >Re: How far with accessors? (From: Jeff Biggus <email@hidden>)

  • Prev by Date: Re: monitoring retainCount
  • Next by Date: Re: How far with accessors?
  • Previous by thread: Re: How far with accessors?
  • Next by thread: Re: How far with accessors?
  • Index(es):
    • Date
    • Thread