• 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: NSMutableArray:arrayWithObjects question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableArray:arrayWithObjects question


  • Subject: Re: NSMutableArray:arrayWithObjects question
  • From: "Stephen Deken" <email@hidden>
  • Date: Fri, 17 Nov 2006 13:11:31 -0600

Is there something about arrayWithObjects that make the array not
valid as a data source? Anyone have any ideas?

I think we're missing the one line that would make the diagnostic difference. In the revised example, are you doing this?

    myArray = [[NSMutableArray alloc] init];
    [myArray addObject:@"One"];
    ...

If so, then the difference is that your first example (using
[arrayWithObjects:]) is creating an autoreleased instance, which is
likely being deallocated shortly thereafter.  If you initialize your
array using [arrayWithObjects:], just call retain on it:

    myArray = [[NSMutableArray arrayWithObjects:@"One", @"Two",
@"Three", nil] retain];

The call to [retain] will cause the array to stick around.  You'll
have to match it with a call to [release] in your object's [dealloc]
method.

Stephen Deken
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSMutableArray:arrayWithObjects question (From: Jay Wooten <email@hidden>)

  • Prev by Date: Re: Non-square (triangular) views
  • Next by Date: Re: NSMutableArray:arrayWithObjects question
  • Previous by thread: NSMutableArray:arrayWithObjects question
  • Next by thread: Re: NSMutableArray:arrayWithObjects question
  • Index(es):
    • Date
    • Thread