Re: NSData encode decode
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