我想要archive
和Unarchive
包含NSDictionary
对象的数据。Unarchiving
在数据时观察到崩溃。请在下面找到代码和错误,
档案:
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:mydictobject];
解档:
NSData *Objdata = [[NSData alloc] initWithBytes:sqlite3_column_blob(statement, 2)
length:sqlite3_column_bytes(statement, 2)];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc]
initForReadingWithData:Objdata];
NSDictionary *dict = [NSDictionary dictionaryWithDictionary:
[NSKeyedUnarchiver unarchiveObjectWithData:Objdata]];
[dict objectForKey:@"key1"];
错误:
* 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0xfffffff8, 0xffffffc7, 0xf, 0x1, 0x2, 0x0, 0x0, 0x0)' * * First throw call stack: (0x222b012 0x194e7e 0x222adeb 0xe78c90 0xe7f2 0x3c11 0x19256 0x43f8d5 0x43fb3d 0xe46e83 0x21ea376 0x21e9e06 0x21d1a82 0x21d0f44 0x21d0e1b 0x21857e3 0x2185668 0x39065c 0x2612 0x2545 0x1) libc++abi.dylib:终止调用抛出异常
谢谢。