On Wed, Aug 18, 2010 at 5:25 PM, Martin Wierschin <mar...@nisus.com> wrote:
> On 2010.08.18, at 2:08 PM, Sherm Pendley wrote:
>
>> Implementing -stringByReplacing... as "return [[self retain]
>> autorelease];" makes the same guarantee, that the object returned by
>> -stringByReplacing... will remain valid if the original string is
>> released.
>
> Yes, but there's no guarantee which technique -stringByReplacing.. will use
> internally.

True, but the MM rules *do* guarantee that -stringByReplacing...* will
return an object that remains valid throughout the caller's scope.
Implementing with a simple "return self;" wouldn't fulfill that
contract, since releasing the original object would then release the
"copy" as well.

* Is anyone else wishing that we'd chosen a shorter method name to
have this discussion? :-)

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.sourceforge.net
_______________________________________________

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