我有一个数组 itemQtyArray,我将其存储在 SQLITE 表中:
NSData *toData = [NSKeyedArchiver archivedDataWithRootObject:self.itemQtyArray];
NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO ORDERTABLE(ITEMDESC,ITEMQTY)VALUES( \"%@\",\"%@\");",dataString2,toData];
然后我检索为:
const void *itemQty = sqlite3_column_text(statement, 2);
NSInteger qtyBytes = sqlite3_column_bytes(statement, 2);
NSData *data2 = [NSData dataWithBytes:itemQty length:qtyBytes];
NSArray *myArrayFromDB = [[NSArray alloc]init];
myArrayFromDB = [NSKeyedUnarchiver unarchiveObjectWithData:data2];
[self.itemQtyArray addObjectsFromArray:myArrayFromDB];
但是我在线上遇到异常
myArrayFromDB = [NSKeyedUnarchiver unarchiveObjectWithData:data2];
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:
'-[__NSCFData objectForKey:]: unrecognized selector sent to instance
请告诉什么是错的