NSArray arrayWithObjects: count: method
NSArray arrayWithObjects: count: method
- Subject: NSArray arrayWithObjects: count: method
- From: Dave Sopchak <email@hidden>
- Date: Sun, 13 Apr 2003 00:17:27 -0700
Hi all,
After R-ing TFM and checking the archives, I haven't found the answer
to my question.
I would like to create an NSArray of objects, ten of the same type.
It looks like the
+ (id)arrayWithObjects:(id *)objs count:(unsigned)cnt;
method would be a good choice.
Would the following code work? Does this method create copies of the
object(s) passed? The double indirection (id *) makes me wonder.
MacdobModule *module;
module = [[MacdobModule alloc] init]; // init a module object
modules = [NSArray arrayWithObjects: &module count:10]; // create
an array of 10 of them
or do I have to alloc the memory for all of this stuff first?
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
The docs seem kind of vague. I wish they had a specific example. Any
help, much appreciated
Dave
_______________________________________________
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.