mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Implement keyed coding for NSURL.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30853 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9f2c523921
commit
e6166d58ba
3 changed files with 78 additions and 32 deletions
|
@ -1149,8 +1149,16 @@ static unsigned urlAlign;
|
|||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeObject: _urlString];
|
||||
[aCoder encodeObject: _baseURL];
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeObject: _baseURL forKey: @"NS.base"];
|
||||
[aCoder encodeObject: _urlString forKey: @"NS.relative"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder encodeObject: _urlString];
|
||||
[aCoder encodeObject: _baseURL];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSUInteger) hash
|
||||
|
@ -1163,15 +1171,21 @@ static unsigned urlAlign;
|
|||
NSURL *base;
|
||||
NSString *rel;
|
||||
|
||||
[aCoder decodeValueOfObjCType: @encode(id) at: &rel];
|
||||
[aCoder decodeValueOfObjCType: @encode(id) at: &base];
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
base = [aCoder decodeObjectForKey: @"NS.base"];
|
||||
rel = [aCoder decodeObjectForKey: @"NS.relative"];
|
||||
}
|
||||
else
|
||||
{
|
||||
rel = [aCoder decodeObject];
|
||||
base = [aCoder decodeObject];
|
||||
}
|
||||
if (nil == rel)
|
||||
{
|
||||
rel = @"";
|
||||
}
|
||||
self = [self initWithString: rel relativeToURL: base];
|
||||
RELEASE(rel);
|
||||
RELEASE(base);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue