Re: NSArray arrayWithObjects: count: method
Re: NSArray arrayWithObjects: count: method
- Subject: Re: NSArray arrayWithObjects: count: method
- From: mmalcolm crawford <email@hidden>
- Date: Sun, 13 Apr 2003 00:46:52 -0700
On Sunday, April 13, 2003, at 12:17 AM, Dave Sopchak wrote:
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.
"Creates and returns an array containing count objects from objects."
Keyword there, "from", as opposed to, say, "copies of".
Would the following code work?
Umm, well, you could test it...
2003-04-13 00:40:37.721 Test[5892] *** Uncaught exception:
<NSInvalidArgumentException> *** -[NSPlaceholderArray
initWithObjects:count:]: attempt to insert nil
Does this method create copies of the object(s) passed?
See above.
for(i = 0; I <10; ++i)
module[i] = [[MacdobModule alloc] init]; // init a module object
OK, but unless you're explicitly releasing the MacdobModule objects in
another iteration later, you're going to get a memory leak...
for(i = 0; i <10; ++i) // i
module[i] = [[[MacdobModule alloc] init] autorelease];
mmalc
_______________________________________________
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.