Re: addObjectsToArray: behaving badly - why?
Re: addObjectsToArray: behaving badly - why?
- Subject: Re: addObjectsToArray: behaving badly - why?
- From: "Hank Heijink (Mailinglists)" <email@hidden>
- Date: Sat, 12 Apr 2008 22:48:45 -0400
Are you sure self.dependencies isn't returning nil? That'd explain it.
Hank
On Apr 12, 2008, at 10:42 PM, K. Darcy Otto wrote:
My code used to look like this:
NSMutableArray *newDependencies = [self.dependencies mutableCopy];
[newDependencies addObjectsFromArray:[aDependency dependencies]];
Now self.dependencies and [aDependency dependencies] both return
NSArrays. The code works very well provided that the array returned
by self.dependencies does not have 0 objects in it. But if the
array returned by self.dependencies does have 0 objects in it, then
newDependencies still has 0 objects in it after addObjectsFromArray
is executed. I was able to correct this behaviour with the
following code:
NSMutableArray *newDependencies = [[NSMutableArray alloc] init];
[newDependencies addObjectsFromArray:self.dependencies];
[newDependencies addObjectsFromArray:[aDependency dependencies]];
This works fine even when the array returned by self.dependencies
has 0 objects. But I'm puzzled as to why it functions differently
than the first version. Any ideas?
_______________________________________________
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:
@runbox.com
This email sent to email@hidden
_______________________________________________
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