Re: NSArray arrayWithObjects: count: method
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.