sqlite for swift is unstable

前端 未结 3 528
谎友^
谎友^ 2020-12-10 03:14

I\'ve set up swift project to use sqlite. sometimes, when inserting it doesn\'t actually insert the correct (or all) the values. I know because I restart the app, and when

3条回答
  •  情歌与酒
    2020-12-10 03:34

    I had the same problem. I found the way to resolve this problem.

    sqlite3_bind_text(statement, 1, itemName, -1, nil) --> itemName should be UTF8 String
    

    You should convert itemName as NSString and use UTF8String to convert your string to UTF8. Right code is the same here

    let itemName = item.itemName as NSString
    sqlite3_bind_text(statement, 1, itemName.UTF8String, -1, nil)
    

    Good luck.

提交回复
热议问题