Re: NSMutableArray:arrayWithObjects question
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