• 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: NSArray arrayWithObjects: count: method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray arrayWithObjects: count: method


  • Subject: Re: NSArray arrayWithObjects: count: method
  • From: Sherm Pendley <email@hidden>
  • Date: Sun, 13 Apr 2003 03:49:05 -0400

On Sunday, April 13, 2003, at 03:17 AM, Dave Sopchak wrote:

+ (id)arrayWithObjects:(id *)objs count:(unsigned)cnt;

Does this method create copies of the object(s) passed? The double indirection (id *) makes me wonder.

No, I don't think it makes copies. The (id *) is just a C array of ids.

MacdobModule *module[10];

for(i = 0; I <10; ++i)
module[i] = [[MacdobModule alloc] init]; // init a module object

modules = [NSArray arrayWithObjects: module count:10]; // create an array of 10 of them

That looks right.

Another way to do it is to avoid the C array entirely, by using an NSMutableArray:

modules = [NSMutableArray arrayWithCapacity: 10];
for(i=0; i<10; i++)
[modules insertObject: [[MacdobModule alloc] init] atIndex: i];

sherm--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSArray arrayWithObjects: count: method
      • From: Dave Sopchak <email@hidden>
References: 
 >NSArray arrayWithObjects: count: method (From: Dave Sopchak <email@hidden>)

  • Prev by Date: Re: NSArray arrayWithObjects: count: method
  • Next by Date: Re: NSArray arrayWithObjects: count: method
  • Previous by thread: Re: NSArray arrayWithObjects: count: method
  • Next by thread: Re: NSArray arrayWithObjects: count: method
  • Index(es):
    • Date
    • Thread