Skip to content

Commit

Permalink
Implemented encodeRootObject method
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Oct 31, 2012
1 parent 99a35a8 commit e278244
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions HRCoder/HRCoder.m
Expand Up @@ -274,8 +274,7 @@ - (id)initForWritingWithMutableData:(NSMutableData *)data
- (id)archiveRootObject:(id)rootObject
{
[_knownObjects removeAllObjects];
if (rootObject) [_knownObjects setObject:rootObject forKey:HRCoderRootObjectKey];
[_stack setArray:[NSMutableArray arrayWithObject:[rootObject archivedObjectWithHRCoder:self]]];
[self encodeRootObject:rootObject];
id plist = [_stack lastObject];
[self finishEncoding];
return plist;
Expand Down Expand Up @@ -342,6 +341,15 @@ - (void)encodeObject:(id)objv forKey:(NSString *)key
if (object) [[_stack lastObject] setObject:object forKey:key];
}

- (void)encodeRootObject:(id)rootObject
{
if (rootObject)
{
[_knownObjects setObject:rootObject forKey:HRCoderRootObjectKey];
[_stack setArray:[NSMutableArray arrayWithObject:[rootObject archivedObjectWithHRCoder:self]]];
}
}

- (void)encodeConditionalObject:(id)objv forKey:(NSString *)key
{
if ([[_knownObjects allValues] containsObject:objv])
Expand Down

0 comments on commit e278244

Please sign in to comment.