Re: Why is [NSArray arrayWithObjects:] failing for me?
Re: Why is [NSArray arrayWithObjects:] failing for me?
- Subject: Re: Why is [NSArray arrayWithObjects:] failing for me?
- From: Roland King <email@hidden>
- Date: Sun, 3 Jan 2010 13:15:48 +0800
On 03-Jan-2010, at 1:10 PM, Yandy Ramirez wrote:
> the method [NSArray arrayWithObjects:] returns an autoreleased object,
> there's no need for you to release it yourself. According to ObjC memory
> management guidelines you only release when you. Retain and object,
> init/alloc and object or copy it. In this case I think your array is getting
> released before you have a chance to use it in your next method.. try this:
>
> NSString* pa = [playerA stringValue];
> NSString* pb = [playerB stringValue];
> NSString* pc = [playerC stringValue];
> NSString* pd = [playerD stringValue];
> NSArray* pnl = [NSArray arrayWithObjects:pa,pb,pc,pd,nil];
> * [pnl retain]; // or use a NSArray *pnl = [[NSArray alloc]
> initWithObjects:] method.*
> [parentDocument setPlayerNameList:pnl];
> [pnl release];
>
>
no need to retain it, just don't release it (ie remove the [ pnl release ] call). _______________________________________________
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