• 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: addObjectsToArray: behaving badly - why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >addObjectsToArray: behaving badly - why? (From: "K. Darcy Otto" <email@hidden>)

  • Prev by Date: addObjectsToArray: behaving badly - why?
  • Next by Date: Re: HUD-style panel controls?
  • Previous by thread: addObjectsToArray: behaving badly - why?
  • Next by thread: NSTextField vertical sizeToFit
  • Index(es):
    • Date
    • Thread