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

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.

  • Follow-Ups:
    • Re: NSArray arrayWithObjects: count: method
      • From: Sherm Pendley <email@hidden>
    • Re: NSArray arrayWithObjects: count: method
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Re: Class can't be removed???
  • Next by Date: Re: NSArray arrayWithObjects: count: method
  • Previous by thread: Re: Class can't be removed???
  • Next by thread: Re: NSArray arrayWithObjects: count: method
  • Index(es):
    • Date
    • Thread