iphone - iOS correct way (memory management) for a method to return a value -


if have class named foo , have function + getids should return ids. correct signature of + getids this:

+ (nsarray *)getids {      nsmutablearray *ids = [[[nsmutablearray alloc] init] autorelease];      return ids; } 

what i'm wondering if should use autorelease on *ids? there no other way assume? can't [ids release] after return statement right?

you can send autorelease message along alloc, init messages. can do, return [ids autorelease]; note: should not both @ same time ;-)

you can not return [id release], because release method returns nothing.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -