我有一个NSMutableArray
NSDictionary
我希望在iOS中存储在sqlite中。我试过了:
in .h
@property (nonatomic,retain) NSMutableArray *mutArrayOfDict;
在sqlite上插入:
NSData *wrtData = [NSKeyedArchiver archivedDataWithRootObject:mutArrayOfDict];
sqlite3_bind_blob(statement, 5, wrtData, -1, SQLITE_TRANSIENT);
在sqlite上阅读:
blob = sqlite3_column_blob(statement, 5);
bytes = sqlite3_column_bytes(statement, 5);
readData = [NSData dataWithBytes:blob length:bytes];
mutArrayOfDict = [NSKeyedUnarchiver unarchiveObjectWithData:readData]; //Exception
异常
[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive....
我试过了:
[NSPropertyListSerialization propertyListFromData:readData
mutabilityOption:NSPropertyListImmutable
format:NULL
errorDescription:nil];
这会在mutArrayOfDict的0索引处插入一个null。 请帮忙!!
答案 0 :(得分:0)
soo如果我说得对,你想从nsmutablearray填充一个sqlite表,为什么不这样做呢?
How to add nsmutable array into sqlite database table
for (int i = 0; i < [mutArray count]; i++)
{
NSString *string = [mutArray objectAtIndex:i];
// insert query
insert into table_name ('string') values(column_name);
}
// iUser