Re: stringByReplacingCharactersInRange leading to bus error
Re: stringByReplacingCharactersInRange leading to bus error
- Subject: Re: stringByReplacingCharactersInRange leading to bus error
- From: Sherm Pendley <email@hidden>
- Date: Wed, 18 Aug 2010 17:45:34 -0400
On Wed, Aug 18, 2010 at 5:25 PM, Martin Wierschin <email@hidden> 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 (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