Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 转换SQLite/FMDB NSArray格式_Objective C_Sqlite_Nsstring_Nsarray_Fmdb - Fatal编程技术网

Objective c 转换SQLite/FMDB NSArray格式

Objective c 转换SQLite/FMDB NSArray格式,objective-c,sqlite,nsstring,nsarray,fmdb,Objective C,Sqlite,Nsstring,Nsarray,Fmdb,关于SQLite和FMDB的问题,我将把NSArray*insertParams保存到SQLite中,insertParams的格式如下: ( { 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”; “邮政标识”=114

关于SQLite和FMDB的问题,我将把NSArray*insertParams保存到SQLite中,insertParams的格式如下:

( { 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”; “邮政标识”=114834; “post_type”=“a”; 得分=1分; title=“\U5927\U5bb6\U6765\U4e3a2013\U5e74\U7684\U65b0\U5e74\U8bb8\U613f\U5427\Uff1f\U4f60\U7684\U613f\U671b\U662f\U4ec0\U4e48\Uff1f”; 用户={ “头像url”=“/statics/images/thumb_d04a6fc94214e61a0f35f70b50387b18.jpg”; id=7151; 姓名=abc; 昵称=abc; }; }, { 行动 ................ ................

但是,当我从SQLite检索数据时,数据被正确保存,因为没有这样的arrayForColumn函数,所以我必须使用stringForColumn函数获取数据,如下所示:

NSString*content=[results stringForColumn:@“content”]

[resultArray addObject:content]

但是,resultArray的格式已更改为以下格式:

( “{\n action=\”\U8d5e\U540c\U4e86\U8be5\U56de\U7b54\”;\n内容= \“\U8c22zolo\U9080\Uff0c\U65b0\U5e74\U5feb\U4e50~\U81ea\U5df1\U548c\U5bb6\U4eba\U8eab\U4f53\U5b89\U5eb7\U3002\”;\n \“post\u id\”=114834;\n“post\u type\”=a\;\n分数=1;\n
头衔= \“\U5927\U5bb6\U6765\U4e3a2013\U5e74\U7684\U65b0\U5e74\U8bb8\U613f\U5427\Uff1f\U4f60\U7684\U613f\U671b\U662f\U4ec0\U4e48\Uff1f\”;\n 用户={\n\“化身\u url\”= \“/statics/images/thumb_d04a6fc94214e61a0f35f70b50387b18.jpg\”;\n
id=7151;\n name=abc;\n昵称=abc;\n};\n}“, “{\n行动 ................ ................

有谁能告诉我如何将结果格式化为原始NSArray*insertParams的格式


非常感谢!

您对这个问题考虑得太多了。FMDB(以及SQL)在处理NSData实例方面非常好,因此您可以简单地使用
NSKeyed(Un)Archiver
将NSData对象转换为数组或从NSData对象转换为数组。在执行查询后,检索它只需调用
-dataForColumn

您已经仔细考虑了这个问题。FMDB(以及SQL)非常适合处理NSData实例,因此您可以简单地使用
NSKeyed(Un)Archiver
将NSData对象转换为数组或从NSData对象转换为数组。执行查询后,只需调用
-dataForColumn
即可检索该对象