• 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: NSData encode decode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData encode decode


  • Subject: Re: NSData encode decode
  • From: Michael Ash <email@hidden>
  • Date: Thu, 2 Apr 2009 21:42:39 -0400

On Thu, Apr 2, 2009 at 6:58 PM, James Maxwell
<email@hidden> wrote:
> Just a quick update... If I do this:
>
> const float *markovBytes = (float *)[coder
> decodeBytesForKey:@"normalizedMarkovGraph" returnedLength:&mGraphSize];
> [self setNormalizedMarkovGraph:[NSData dataWithBytes:markovBytes
> length:mGraphSize]];

Why don't you just use encodeObject:forKey: and decodeObjectForKey: to
save and load the NSData object directly? There's no need to manually
squirrel away the bytes and length like this.

If you still have problems, post the actual text of the exception
that's thrown and the full backtrace from when it happens.

Note that with either technique, you need to perform byteswapping if
you want the archived files to work on different CPU architectures,
for example between PPC and i386. There are functions in NSByteOrder.h
which can help with this.

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: 
 >NSData encode decode (From: James Maxwell <email@hidden>)
 >Re: NSData encode decode (From: James Maxwell <email@hidden>)

  • Prev by Date: Re: NSPopUpButton pullsDown:YES and dummy first item - normal?
  • Next by Date: Re: Toll-free bridge type at runtime
  • Previous by thread: Re: NSData encode decode
  • Next by thread: Re: NSData encode decode
  • Index(es):
    • Date
    • Thread