Re: NSString's "mutableCopy" creating a leak?
Re: NSString's "mutableCopy" creating a leak?
- Subject: Re: NSString's "mutableCopy" creating a leak?
- From: "Sherm Pendley" <email@hidden>
- Date: Wed, 1 Oct 2008 15:54:33 -0400
On Wed, Oct 1, 2008 at 3:34 PM, Christopher J Kemsley <email@hidden>wrote:
> I'm writing a program that, in one table view, has the following code:
>
> id receivedName = [theDatabase itemAtIndex:editedRow] ;
>> editedRowName = [receivedName mutableCopy] ;
>> [receivedName release];
>>
>
> where "editedRowName" is defined as an NSMutableString.
...
> Does anybody know where this leak is coming from?
You're not following the standard memory-management rules. You created an
object with a method with "copy" in its name, therefore you're obligated to
release that object.
<
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html
>
(Before anybody yells at me saying that the iPhone SDK cannot be discussed
> here, read this: http://developer.apple.com/iphone/program/ )
This discussion is kosher because it's equally applicable to Cocoa on Mac OS
X, and would have been kosher regardless of whether the NDA was still in
effect or not.
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