I know you guys probably know this, but to be technically accurate, there is no guarantee the return value of stringByAppendingString returns an autoreleased string.

While your point is true, it's not actually a rebuttal - you can assume objects returned from such methods are autoreleased, because that's the contract given. Whether they're cached or singletons or whatever else, they must obey the policy that they'll stick around 'til the next flush of the current thread's current autorelease pool. You just can't safely handle the memory management otherwise, especially in multithreaded cases.

Unfortunately, this contract isn't always followed. Lots of people "optimise" away this policy instead of doing a "superfluous" 'return [[foo retain] autorelease]'. @propertys are by default atomic (meaning they follow this policy) for a reason. In manually written code, you have to be careful, but you're pretty safe with object creation methods, and especially those in Apple frameworks. If you find any that don't follow this policy, you should file a bug report.

Wade
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to