I have a NSMutableArray
of NSDictionary
which I want to store in sqlite in iOS. I tried:
in .h
@property (nonatomic,retain) NSMutableArray *mutArrayOfDict;
At sqlite insert:
NSData *wrtData = [NSKeyedArchiver archivedDataWithRootObject:mutArrayOfDict];
sqlite3_bind_blob(statement, 5, wrtData, -1, SQLITE_TRANSIENT);
At sqlite read:
blob = sqlite3_column_blob(statement, 5);
bytes = sqlite3_column_bytes(statement, 5);
readData = [NSData dataWithBytes:blob length:bytes];
mutArrayOfDict = [NSKeyedUnarchiver unarchiveObjectWithData:readData]; //Exception
Exception
[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive....
I tried:
[NSPropertyListSerialization propertyListFromData:readData
mutabilityOption:NSPropertyListImmutable
format:NULL
errorDescription:nil];
And this inserts a null at 0 index of mutArrayOfDict. Please help!!
soo if I get you right you want to populate a sqlite table from a nsmutablearray so why not do this ?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.