• 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: Initialize NSArray with C array?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Initialize NSArray with C array?


  • Subject: Re: Initialize NSArray with C array?
  • From: Allan Odgaard <email@hidden>
  • Date: Thu, 23 Sep 2004 07:12:44 +0200

On 23. Sep 2004, at 3:30, Scott Stevenson wrote:

Is there a simple efficient way to initialize a NSArray with a C array of doubles (converting them to NSNumbers in the process)? [...]

Oh... I completely missed the chance of mentioning CocoaSTL...

   double src[] = { ... };
   NSMutableArray* dst = ...;

   std::transform(beginof(src), endof(src), back_inserter(dst),
      unary_method<double>("numberWithDouble:")([NSNumber class]));

While "simple" here can be questioned, but it's short and avoids the loop ;)
--
http://macromates.com/ ::: TextMate, OS X text editor
http://macromates.com/sigpipe/ ::: Personal weblog about programming


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Initialize NSArray with C array? (From: dkb <email@hidden>)
 >Re: Initialize NSArray with C array? (From: Scott Stevenson <email@hidden>)

  • Prev by Date: Newbie requires java assistance...
  • Next by Date: Downloading files via HTTP with 304 support?
  • Previous by thread: Re: Initialize NSArray with C array?
  • Next by thread: Howto find the Outlet name Of a drag destination? OR Howto update model with Drag and Drop in the cocoa dialect?
  • Index(es):
    • Date
    • Thread