Re: stringByReplacingCharactersInRange leading to bus error
Re: stringByReplacingCharactersInRange leading to bus error
- Subject: Re: stringByReplacingCharactersInRange leading to bus error
- From: Kyle Sluder <email@hidden>
- Date: Wed, 18 Aug 2010 13:22:22 -0700
On Wed, Aug 18, 2010 at 12:49 PM, Sherm Pendley <email@hidden> wrote:
> The "[foo release]" is perfectly correct, but if
> -stringByReplacingOccurrencesOfString:withString: is implemented with
> a simple "return self;" then *both* foo and bar would be immediately
> released. Implementing it as "return [[self retain] autorelease]"
> prevents such problems.
It doesn't violate the memory management guidelines to do so. The onus
is technically on the caller to retain bar if he wants to use it
later. See: http://developer.apple.com/mac/library/documentation/cocoa/conceptual/MemoryMgmt/Articles/mmAccessorMethods.html
--Kyle Sluder
_______________________________________________
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