0

I'm getting odd exception:

-[NSKeyedUnarchiver initForReadingWithData:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?

when deserializing object that was previously archived with NSKeyedArchiver and transferred over the network. Everything works properly though (the data is the same), but this exception kept logging is annoying. Exception does not occur, however, when I serialize-deserialize locally.

Here's how I serialize object:

NSData *payload = [NSKeyedArchiver archivedDataWithRootObject:object];

Here's how I deserialize object:

NCNamespaceObject *object = [NSKeyedUnarchiver unarchiveObjectWithData:payload];

Here's object's encodeWithCoder: method (super's method is empty):

-(void)encodeWithCoder:(NSCoder *)aCoder
{
    [super encodeWithCoder:aCoder];
    [aCoder encodeObject:self.text forKey:@"text"];
}

And finally, here's the object's initializer:

-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super initWithCoder:aDecoder])
    {
        _text = [aDecoder decodeObjectForKey:@"text"];
    }
    return self;
}

Not sure why it keeps posting this error...

peetonn
  • 2,942
  • 4
  • 32
  • 49

0 Answers0