• 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: Best way to pass large objects between tasks?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to pass large objects between tasks?


  • Subject: Re: Best way to pass large objects between tasks?
  • From: Michael Ash <email@hidden>
  • Date: Tue, 14 Apr 2009 11:34:58 -0400

On Tue, Apr 14, 2009 at 9:23 AM, Karan, Cem (Civ, ARL/CISD)
<email@hidden> wrote:
>> >I haven't tried either of the methods I mentioned so far
>> (because I'm
>> >lazy, sorry:), but what I have tried is I created NSData
>> from the large
>> >object by using NSKeyedArchiver. It has taken forever, so
>> that I had to
>> >force-quit the process. That's why I am asking if the same thing is
>> >going to happen with piples and DO? Or maybe I'm doing
>> something wrong?
>>
>>   If your data has many double values and use encodeDouble:forKey:
>> use encodeBytes:length:forKey: instead.  encodeDouble:forKey:
>> is very very slow. In my case, with encodeDouble:forKey: it
>> takes 4 hour and 30 minutes, but with
>> encodeBytes:length:forKey: it takes only 21 seconds.
>> I never tested for float values but maybe the same.
>
> That may not be the safest way to do things; if you encode on a little
> endian machine and decode on a big endian one, the bytes that make up
> the double may be swapped.  You might be able to do this if you first
> encode a constant that has a known pattern as a double, and then encode
> all your doubles afterwards.  That way, as you are decoding, you can use
> some special purpose swap logic to get the bytes in the right order on
> your machine by seeing how the known pattern was mangled when it was
> archived.

It is perfectly safe as long as you actually do it properly. Doing it
properly does of course involve swapping the numbers as you put them
in and get them out of the archive. Encoding a known pattern is a
horrible idea, don't do this. Use NSSwapHostDoubleToBig and
NSwapBigDoubleToHost in NSByteOrder.h to produce a consistent ordering
and format.

Mike
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Best way to pass large objects between tasks? (From: "Karan, Cem (Civ, ARL/CISD)" <email@hidden>)

  • Prev by Date: Re: Autosaving the selection in an NSTableView
  • Next by Date: updating NSTextField with key validation?
  • Previous by thread: Re: Best way to pass large objects between tasks?
  • Next by thread: Display NSTextView as Label - without InterfaceBuilder
  • Index(es):
    • Date
    • Thread