Weird NSUnarchiver "more data than room " exception
Weird NSUnarchiver "more data than room " exception
- Subject: Weird NSUnarchiver "more data than room " exception
- From: Mike Laster <email@hidden>
- Date: Fri, 3 Oct 2003 13:46:28 -0400
I'm running into a strange NSUnarchiver exception. I have an
NSDictionary with NSString keys, and a custom object value
(MRealtimePrice).
I archive/unarchive the dictionary and occasionally during the
NSUnarchive, I receive a "NSRangeException: more data than room"
exception with the following backtrace:
#0 0x97e5487c in -[NSException raise] ()
#1 0x97e54804 in +[NSException raise:format:] ()
#2 0x97ef2db4 in _decodeLongAtCursor ()
#3 0x97df5084 in _decodeValueOfObjCType ()
#4 0x97e02ed8 in -[NSUnarchiver decodeValueOfObjCType:at:] ()
#5 0x0038bb40 in -[MRealtimePrice initWithCoder:] ()
#6 0x97df48b4 in _decodeObject ()
#7 0x97df50e8 in _decodeValueOfObjCType ()
#8 0x97e02ed8 in -[NSUnarchiver decodeValueOfObjCType:at:] ()
#9 0x97e0c964 in -[NSDictionary initWithCoder:] ()
#10 0x97df48b4 in _decodeObject ()
#11 0x97e44fec in +[NSUnarchiver unarchiveObjectWithData:] ()
Any idea what could cause this? Here are some details of my
implementation.
My ivars for MRealtimePrice are:
{
unsigned long currentPrice;
char decimalPrecision;
unsigned long highPrice;
unsigned long lowPrice;
long netChange;
long percentNetChange;
unsigned long openPrice;
unsigned long cumulativeVolume;
unsigned long previousClose;
unsigned short lastTrade;
}
and my NSCoder methods are:
- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeValueOfObjCType:@encode(unsigned long)
at:¤tPrice];
[coder encodeValueOfObjCType:@encode(char) at:&decimalPrecision];
[coder encodeValueOfObjCType:@encode(unsigned long) at:&highPrice];
[coder encodeValueOfObjCType:@encode(unsigned long) at:&lowPrice];
[coder encodeValueOfObjCType:@encode(long) at:&netChange];
[coder encodeValueOfObjCType:@encode(long) at:&percentNetChange];
[coder encodeValueOfObjCType:@encode(unsigned long) at:&openPrice];
[coder encodeValueOfObjCType:@encode(unsigned long)
at:&cumulativeVolume];
[coder encodeValueOfObjCType:@encode(unsigned long)
at:&previousClose];
[coder encodeValueOfObjCType:@encode(unsigned short) at:&lastTrade];
return;
}
- (id)initWithCoder:(NSCoder *)coder
{
[coder decodeValueOfObjCType:@encode(unsigned long)
at:¤tPrice];
[coder decodeValueOfObjCType:@encode(char) at:&decimalPrecision];
[coder decodeValueOfObjCType:@encode(unsigned long) at:&highPrice];
[coder decodeValueOfObjCType:@encode(unsigned long) at:&lowPrice];
[coder decodeValueOfObjCType:@encode(long) at:&netChange];
[coder decodeValueOfObjCType:@encode(long) at:&percentNetChange];
[coder decodeValueOfObjCType:@encode(unsigned long) at:&openPrice];
[coder decodeValueOfObjCType:@encode(unsigned long)
at:&cumulativeVolume];
[coder decodeValueOfObjCType:@encode(unsigned long)
at:&previousClose];
[coder decodeValueOfObjCType:@encode(unsigned short) at:&lastTrade];
return self;
}
When catching it under the debugging, it is getting the exception while
decoding percentNetChange.
As far as I can tell, everything here is correct. Can anyone shed some
light on this?
Also, this is running on 10.2.6.
_______________________________________________
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.