Re: Methods that return autoreleased objects?
Re: Methods that return autoreleased objects?
- Subject: Re: Methods that return autoreleased objects?
- From: "Owen Yamauchi" <email@hidden>
- Date: Sat, 28 Jun 2008 18:29:22 -0700
Don't think about it.
If memory management confuses you in any way, don't try to think about
the status of objects returned from framework methods. Only worry
about it from the perspective of your code. Do you need the object to
stay around after your method returns? Then retain it, and remember to
release it somewhere else as appropriate. If you make an object with
+alloc or -copy, then you'll need to release it somewhere too.
In practice, most framework methods return autoreleased objects (if
the method creates it). There are other situations, for example:
-[NSArray objectAtIndex:] will return an object that is retained by
the array, and is not in any autorelease pools (unless you've put it
in one). But that's because the object was not created by the array.
Bottom line: don't think about it. Follow the rules in your own code,
and all will be well.
Owen
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden