• 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: Unarchiving issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unarchiving issues


  • Subject: Re: Unarchiving issues
  • From: glenn andreas <email@hidden>
  • Date: Mon, 02 Aug 2010 12:56:52 -0500

On Aug 2, 2010, at 12:46 PM, James Maxwell wrote:

> 		// set the contents of the array
> 		continuations = (float*)[aDecoder decodeBytesForKey:@"continuations" returnedLength:&size];



>From the header file:

- (const uint8_t *)decodeBytesForKey:(NSString *)key returnedLength:(NSUInteger *)lengthp;	// returned bytes immutable, and they go away with the unarchiver, not the containing autorlease pool

And from the documentation:
Discussion
The returned value is a pointer to a temporary buffer owned by the receiver. The buffer goes away with the unarchiver, not the containing autorelease pool. You must copy the bytes into your own buffer if you need the data to persist beyond the life of the receiver.




So if your setContinuationSize: allocates memory, you should:

	const uint8_t *bytes = [aDecoder decodeBytesForKey:@"continuations" returnedLength:&size];
	NSAssert(size == [self continuationsSize] * sizeof(float), @"Bad size of bytes returned from decoding");
	memcpy(continuations, bytes, size);



Glenn Andreas                      email@hidden
The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL

_______________________________________________

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: 
 >Unarchiving issues (From: James Maxwell <email@hidden>)
 >Re: Unarchiving issues (From: Michael Ash <email@hidden>)
 >Re: Unarchiving issues (From: James Maxwell <email@hidden>)

  • Prev by Date: Re: Unarchiving issues
  • Next by Date: Re: [iPhone] Data protection clarification needed.
  • Previous by thread: Re: Unarchiving issues
  • Next by thread: Using an NSToolbar in a sheet
  • Index(es):
    • Date
    • Thread