• 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: NSKeyedArchiver finishEncoding takes forever
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSKeyedArchiver finishEncoding takes forever


  • Subject: Re: NSKeyedArchiver finishEncoding takes forever
  • From: Markus Spoettl <email@hidden>
  • Date: Wed, 18 Jun 2008 20:48:30 -0700

On Jun 18, 2008, at 2:41 PM, Michael Ash wrote:
Although it partially defeats the purpose of using NSCoder, you'll
avoid this whole path if you stuff all four doubles into a single
NSData. Don't forget to use the byte-swapping functions to ensure that
they all have a consistent representation across architectures.


Well, what can I say, you and Quincey Morris are absolutely right. This is the way to go.

The same data set takes just 4 seconds to store with a file size of 17.2MB.

Thanks for all the help guys! For the record I'm posting the code below.

Regards
Markus

- (void)encodeDouble:(double)value forKey:(NSString *)key withCoder: (NSCoder *)encoder
{
NSSwappedDouble sd = NSSwapHostDoubleToLittle(value);
[encoder encodeBytes:(const uint8_t *)&sd length:sizeof(NSSwappedDouble) forKey:key];
}


- (double)decodeDoubleForKey:(NSString *)key withCoder:(NSCoder *)decoder
{
double result = 0.0;
NSUInteger retsize;
NSSwappedDouble *sd = (NSSwappedDouble *)[decoder decodeBytesForKey:key returnedLength:&retsize];
if (retsize == sizeof(NSSwappedDouble)) {
result = NSSwapLittleDoubleToHost(*sd);
}
return result;
}


--
__________________________________________
Markus Spoettl

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

  • Follow-Ups:
    • Re: NSKeyedArchiver finishEncoding takes forever
      • From: "Mark Munz" <email@hidden>
    • Re: NSKeyedArchiver finishEncoding takes forever
      • From: "Michael Ash" <email@hidden>
References: 
 >NSKeyedArchiver finishEncoding takes forever (From: Markus Spoettl <email@hidden>)
 >Re: NSKeyedArchiver finishEncoding takes forever (From: "Michael Ash" <email@hidden>)
 >Re: NSKeyedArchiver finishEncoding takes forever (From: Markus Spoettl <email@hidden>)
 >Re: NSKeyedArchiver finishEncoding takes forever (From: Quincey Morris <email@hidden>)
 >Re: NSKeyedArchiver finishEncoding takes forever (From: Markus Spoettl <email@hidden>)
 >Re: NSKeyedArchiver finishEncoding takes forever (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Re: [NSOutlineView/NSTableView] Returning nil enables auto-edition?
  • Next by Date: Re: NSKeyedArchiver finishEncoding takes forever
  • Previous by thread: Re: NSKeyedArchiver finishEncoding takes forever
  • Next by thread: Re: NSKeyedArchiver finishEncoding takes forever
  • Index(es):
    • Date
    • Thread