• 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: Why is [NSArray arrayWithObjects:] failing for me?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Why is [NSArray arrayWithObjects:] failing for me? (From: Charles Jenkins <email@hidden>)
 >Re: Why is [NSArray arrayWithObjects:] failing for me? (From: Yandy Ramirez <email@hidden>)

  • Prev by Date: Re: Why is [NSArray arrayWithObjects:] failing for me?
  • Next by Date: Re: Why is [NSArray arrayWithObjects:] failing for me?
  • Previous by thread: Re: Why is [NSArray arrayWithObjects:] failing for me?
  • Next by thread: Re: Why is [NSArray arrayWithObjects:] failing for me?
  • Index(es):
    • Date
    • Thread