• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: stringByReplacingCharactersInRange leading to bus error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: stringByReplacingCharactersInRange leading to bus error
      • From: Martin Wierschin <email@hidden>
References: 
 >stringByReplacingCharactersInRange leading to bus error (From: James Miller <email@hidden>)
 >Re: stringByReplacingCharactersInRange leading to bus error (From: "John C. Randolph" <email@hidden>)
 >Re: stringByReplacingCharactersInRange leading to bus error (From: Murat Konar <email@hidden>)
 >Re: stringByReplacingCharactersInRange leading to bus error (From: Sherm Pendley <email@hidden>)
 >Re: stringByReplacingCharactersInRange leading to bus error (From: Kyle Sluder <email@hidden>)
 >Re: stringByReplacingCharactersInRange leading to bus error (From: Sherm Pendley <email@hidden>)
 >Re: stringByReplacingCharactersInRange leading to bus error (From: Kyle Sluder <email@hidden>)
 >Re: stringByReplacingCharactersInRange leading to bus error (From: Sherm Pendley <email@hidden>)
 >Re: stringByReplacingCharactersInRange leading to bus error (From: Martin Wierschin <email@hidden>)

  • Prev by Date: Re: stringByReplacingCharactersInRange leading to bus error
  • Next by Date: Re: stringByReplacingCharactersInRange leading to bus error
  • Previous by thread: Re: stringByReplacingCharactersInRange leading to bus error
  • Next by thread: Re: stringByReplacingCharactersInRange leading to bus error
  • Index(es):
    • Date
    • Thread