• 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: Weird NSUnarchiver "more data than room " exception
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird NSUnarchiver "more data than room " exception


  • Subject: Re: Weird NSUnarchiver "more data than room " exception
  • From: Mike Laster <email@hidden>
  • Date: Fri, 3 Oct 2003 16:40:15 -0400

In experimenting I tracked it down. It appears to be a bug in Foundation. It is incapable of encoding the long value of -2147483648. Decoding it generates the exception I get.

Here is a test program that exhibits the bug:

#import <Foundation/Foundation.h>

@interface TestClass: NSObject <NSCoding>
{
long longValue;
}
@end

@implementation TestClass

- (id) init
{
self = [super init];
if (self != nil)
{
NSLog(@"LONG_MIN is %ld (%#x)", LONG_MIN, LONG_MIN);
NSLog(@"LONG_MAX is %ld (%#x)", LONG_MAX, LONG_MAX);
longValue = -2147483648L;
NSLog(@"logValue initialized to %ld (%#x)", longValue, longValue);
}

return self;
}

- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeValueOfObjCType:@encode(long) at:&longValue];

return;
}

- (id)initWithCoder:(NSCoder *)coder
{
[coder decodeValueOfObjCType:@encode(long) at:&longValue];

return self;
}

@end

int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
TestClass *test = [[TestClass alloc] init];
NSData *archivedData = nil;
TestClass *decoded = nil;

archivedData = [NSArchiver archivedDataWithRootObject:test];
NSLog(@"archived to %@", archivedData);
decoded = [NSUnarchiver unarchiveObjectWithData:archivedData];

[test release];
[pool release];
return 0;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Weird NSUnarchiver "more data than room " exception
      • From: "Alastair J.Houghton" <email@hidden>
References: 
 >Weird NSUnarchiver "more data than room " exception (From: Mike Laster <email@hidden>)

  • Prev by Date: Re: How to locate bundle by bundleID?
  • Next by Date: Re: Weird NSUnarchiver "more data than room " exception
  • Previous by thread: Weird NSUnarchiver "more data than room " exception
  • Next by thread: Re: Weird NSUnarchiver "more data than room " exception
  • Index(es):
    • Date
    • Thread