add keyed archiving support

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26909 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2008-10-12 19:08:24 +00:00
parent 33a4784b8e
commit da5b051cd2
2 changed files with 20 additions and 6 deletions

View file

@ -1,3 +1,7 @@
2008-10-12 Larry Campbelln
* Source/NSDate.m: Add keyed archiving support.
2008-10-11 Eric Wasylishen
* Source/NSBundle.m: fix bug #24320

View file

@ -1003,7 +1003,10 @@ otherTime(NSDate* other)
{
NSTimeInterval interval = [self timeIntervalSinceReferenceDate];
[coder encodeValueOfObjCType: @encode(NSTimeInterval) at: &interval];
if ([coder allowsKeyedCoding])
[coder encodeDouble: interval forKey: @"NS.time"];
else
[coder encodeValueOfObjCType: @encode(NSTimeInterval) at: &interval];
}
- (id) initWithCoder: (NSCoder*)coder
@ -1011,7 +1014,10 @@ otherTime(NSDate* other)
NSTimeInterval interval;
id o;
[coder decodeValueOfObjCType: @encode(NSTimeInterval) at: &interval];
if ([coder allowsKeyedCoding])
interval = [coder decodeDoubleForKey: @"NS.time"];
else
[coder decodeValueOfObjCType: @encode(NSTimeInterval) at: &interval];
if (interval == DISTANT_PAST)
{
o = RETAIN([abstractClass distantPast]);
@ -1343,14 +1349,18 @@ otherTime(NSDate* other)
- (void) encodeWithCoder: (NSCoder*)coder
{
[coder encodeValueOfObjCType: @encode(NSTimeInterval)
at: &_seconds_since_ref];
if ([coder allowsKeyedCoding])
[coder encodeDouble:_seconds_since_ref forKey:@"NS.time"];
else
[coder encodeValueOfObjCType: @encode(NSTimeInterval) at: &_seconds_since_ref];
}
- (id) initWithCoder: (NSCoder*)coder
{
[coder decodeValueOfObjCType: @encode(NSTimeInterval)
at: &_seconds_since_ref];
if ([coder allowsKeyedCoding])
_seconds_since_ref = [coder decodeDoubleForKey:@"NS.time"];
else
[coder decodeValueOfObjCType: @encode(NSTimeInterval) at: &_seconds_since_ref];
return self;
}