FMDB 未插入数据库
我正在尝试使用 FMDB 将一些查询插入到数据库中。
当我检查插入查询时,它说它正在插入。
后来我实际上可以从表中读取数据。
但发生的情况是,如果我尝试从数据库读取信息,它会返回空值。
当我检查 Xcode 项目中的数据库时,似乎没有更新。
这让我有点困惑。有什么建议可能是什么问题吗?
I am trying to use FMDB to insert a few queries into the DB.
When I check the query for insert it is saying that it is inserting.
Later I can actually read the data from the Tables.
But what happens is that if I try to read the information from the DB, it comes back as null.
When I checked the DB in the Xcode Project, not seems to have updated.
It kind of confusing me. Any suggestion what the problem could be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的代码是错误的。这就是我用来写:
和读:
还要检查我定位数据库的位置。我认为按照您的方式进行操作可以在模拟器上运行,但由于沙箱等原因而无法在设备上运行。
祝你好运!
编辑:
将其放入您的应用程序委托中:
并从
application:didFinishLaunchingWithOptions
运行该方法:确保首先将数据库放入项目树中。
Your code is wrong. This is what I use to write:
And to read:
Also checkout where I located the db. I think doing your way will work on simulator but not on the device because of sandboxing and all.
Good luck!
EDIT:
Put this in your app delegate:
And run that method from
application:didFinishLaunchingWithOptions
with:Be sure that you put your database in your projecttree first.