• 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: Autorelease accessors, was Re: NSEnumerator retaining objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Autorelease accessors, was Re: NSEnumerator retaining objects?


  • Subject: Re: Autorelease accessors, was Re: NSEnumerator retaining objects?
  • From: Ricky Sharp <email@hidden>
  • Date: Wed, 09 Mar 2005 12:30:39 -0600

On Wednesday, March 09, 2005, at 11:39AM, Mike R. Manzano <email@hidden> wrote:

>Is this an autorelease accessor?
>
>- (NSString*) getSomething
>{
>	return [ NSString stringWithString:@"blah blah blah" ] ;
>}
>
>or
>
>- (NSString*) getSomethingElse
>{
>	return [ [ [ aClass alloc ] init ] autorelease ] ;
>}

Both of these utlitmately return an autoreleased NSString instance.

>If so, I thought these were preferred ways of doing things?

It really depends.  I typically use the 'return [[_object retain] autorelease]' pattern.  But, there are cases where other patterns need to be used (e.g. returning a mutable copy of the object).

Definitely read up on the advantages/disadvantages of each pattern.  I don't have the link handy, but there's a very good read on all this.  I think mmalc put it together; the link I believe is one of those he has in his 'cocoa resources reminder' e-mails that is sent out every so often.

Finally, if you use Accessorizer, you can pick from many patterns to use for your accessors.

--
Rick Sharp
Instant Interactive(tm)

 _______________________________________________
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

  • Follow-Ups:
    • Re: Autorelease accessors, was Re: NSEnumerator retaining objects?
      • From: mmalcolm crawford <email@hidden>
References: 
 >Re: NSEnumerator retaining objects? (From: James Bucanek <email@hidden>)
 >Re: NSEnumerator retaining objects? (From: mmalcolm crawford <email@hidden>)
 >Re: NSEnumerator retaining objects? (From: Shaun Wexler <email@hidden>)
 >Re: NSEnumerator retaining objects? (From: j o a r <email@hidden>)
 >Re: NSEnumerator retaining objects? (From: Shaun Wexler <email@hidden>)
 >Re: NSEnumerator retaining objects? (From: j o a r <email@hidden>)
 >Re: NSEnumerator retaining objects? (From: Marco Scheurer <email@hidden>)
 >Autorelease accessors, was Re: NSEnumerator retaining objects? (From: "Mike R. Manzano" <email@hidden>)

  • Prev by Date: Re: NSEnumerator retaining objects?
  • Next by Date: [OT] Re: NSEnumerator retaining objects?
  • Previous by thread: Autorelease accessors, was Re: NSEnumerator retaining objects?
  • Next by thread: Re: Autorelease accessors, was Re: NSEnumerator retaining objects?
  • Index(es):
    • Date
    • Thread