Why is NSKeyedArchiver performance so poor? The size doubles vs using NSArchiver.
I am encoding an NSMutableArray of objects with the following line
BOOL result = [NSArchiver archiveRootObject:self.appDataObject.materias toFile:archivePath];
the NSMutableArray contain custom objects that have their corresponding encodeWithCoder and initWithCoder
-(void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject: _fileName];
[aCoder encodeObject: _categoria];
[aCoder encodeObject: _materia];
[aCoder encodeObject: _nombre];
[aCoder encodeObject: _position];
[aCoder encodeValueOfObjCType:@encode(BOOL) at:&_favorite];
}
-(id)initWithCoder:(NSCoder *)aDecoder
{
if (self=[super init]) {
[self setFileName:[aDecoder decodeObject]];
[self setCategoria:[aDecoder decodeObject]];
[self setMateria:[aDecoder decodeObject]];
[self setNombre:[aDecoder decodeObject]];
[self setPosition:[aDecoder decodeObject]];
[aDecoder decodeValueOfObjCType:@encode(BOOL) at:&_favorite];
}
return self;
}
it works fine as it saves the file properly and then I am able to unarchive it. They are around 3000 objects and the output file is about 900kB
The problem occurs when I change my archiving line to:
BOOL result = [NSKeyedArchiver archiveRootObject:self.appDataObject.materias toFile:archivePath];
Everything magically works BUT the file size more than doubles to 2MB!
Why am I asking this? because I am developing a iOS application and therefore lose support of NSArchiver.