Question about SQLite and FMDB, I'm going to save NSArray *insertParams into SQLite, the format of insertParams is like below:
( { action = "\U8d5e\U540c\U4e86\U8be5\U56de\U7b54"; content = "\U8c22zolo\U9080\Uff0c\U65b0\U5e74\U5feb\U4e50~\U81ea\U5df1\U548c\U5bb6\U4eba\U8eab\U4f53\U5b89\U5eb7\U3002"; "post_id" = 114834; "post_type" = "a"; score = 1; title = "\U5927\U5bb6\U6765\U4e3a2013\U5e74\U7684\U65b0\U5e74\U8bb8\U613f\U5427\Uff1f\U4f60\U7684\U613f\U671b\U662f\U4ec0\U4e48\Uff1f"; user = { "avatar_url" = "/statics/images/thumb_d04a6fc94214e61a0f35f70b50387b18.jpg"; id = 7151; name = abc; nickname = abc; }; }, { action ................ ................ ................
The data was perfactly saved, however, when I retrive the data from SQLite, because there is no such arrayForColumn function, so I have to use stringForColumn function to get data as below:
NSString *content = [results stringForColumn:@"content"];
[resultArray addObject:content];
However the format of the resultArray has been changed to below:
( "{\n action = \"\U8d5e\U540c\U4e86\U8be5\U56de\U7b54\";\n content = \"\U8c22zolo\U9080\Uff0c\U65b0\U5e74\U5feb\U4e50~\U81ea\U5df1\U548c\U5bb6\U4eba\U8eab\U4f53\U5b89\U5eb7\U3002\";\n \"post_id\" = 114834;\n \"post_type\" = \"a\";\n score = 1;\n
title = \"\U5927\U5bb6\U6765\U4e3a2013\U5e74\U7684\U65b0\U5e74\U8bb8\U613f\U5427\Uff1f\U4f60\U7684\U613f\U671b\U662f\U4ec0\U4e48\Uff1f\";\n user = {\n \"avatar_url\" = \"/statics/images/thumb_d04a6fc94214e61a0f35f70b50387b18.jpg\";\n
id = 7151;\n name = abc;\n nickname = abc;\n };\n}", "{\n action ................ ................ ................
Could any one tell me that how to format the result as the original NSArray *insertParams's format?
Thanks a lot!
You're over thinking the problem a bit. FMDB (and consequently, SQL) is quite good about handling NSData instances, so you can simply use NSKeyed(Un)Archiver
to convert to and from the NSData object to your array. Retrieving it is a matter of calling -dataForColumn
after executing your query.