Having issues with Unarchiving the data

Hi

I am getting below error while unarchiving my objective-c custom class.

Error Domain=NSCocoaErrorDomain Code=4864 ""* -[NSKeyedUnarchiver initForReadingFromData:error:throwLegacyExceptions:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?"" UserInfo={NSDebugDescription=* -[NSKeyedUnarchiver initForReadingFromData:error:throwLegacyExceptions:]: data is empty; did you forget to send -finishEncoding to the NSKeyedArchiver?}"

I am using the method [NSKeyedUnarchiver unarchivedObjectOfClass:[BBUserInfo class] fromData:data error:&error] to un archive the data.

My custom object is confirm to NSSecureCoding and implemented protocol method as below
  • (BOOL)supportsSecureCoding {

    return YES;
}

Also this error doesn't reproduce for me, Its happening in the App Store released version. I am able to figure this error only through the logs.

I'm a bit of a confused especially in regards to NSKeyedArchiver but where am I supposed to send -finishEncoding to the NSKeyedArchiver. Since finishEncoding is a instance method were as I am using class method to unarchive.

Can some one help me on this?
This error doesn’t indicates an unarchiving problem but an archiving one. The NSData you passed to the unarchiver is empty, that is, it contains 0 bytes. Clearly that’s not valid, so you need to look at the archiving side (or possibly the code that reads the data) to figure out how you got to that point.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Having issues with Unarchiving the data
 
 
Q