iPhone 版 Sqlite 的替代品 [monotouch]
正如标题所说。
我发现我遇到的很多问题都与在 Monotouch 中使用 Sqlite 所需的 Sqlite 包装器中缺乏线程安全有关 - 所以 - 问题是 - 有替代方案吗?一定有某些东西!!?
w://
Like the title says.
I find a lot of the issues I have are related to the lack of thread safety in the Sqlite wrapper needed for using Sqlite with Monotouch - so - the question is - is there an alternative? There must be something!!?
w://
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Sqlite本身不是线程安全的,因此每次访问数据库时都需要手动加锁。您可以看到我如何使用 TweetStation 做到这一点:
http://github.com/migueldeicaza/TweetStation/
这允许我在后台更新数据库。
有几个到 Sqlite 的绑定:sqlite-net,它是一个小型的 Sqlite 绑定或 Mono.Data.Sqlite。
至于CoreData,它也会有同样的问题,你不能免费获得线程安全,你也需要遵循他们的规则。
Sqlite itself is not thread safe, so you need to manually take a lock whenever you are going to access the database. You can see how I did this with TweetStation:
http://github.com/migueldeicaza/TweetStation/
This allows me to update the database in the background.
There are a couple of bindings to Sqlite: sqlite-net which is a tiny Sqlite binding or Mono.Data.Sqlite.
As for CoreData, it would have the same problems, you do not get thread safety for free, you need to follow their rules as well.
在 iOS 4 中,您可以调用 sqlite3_config( SQLITE_CONFIG_SERIALIZED ),或在 C# 中使用 Sqlite3 包装器:
In iOS 4, you can call sqlite3_config( SQLITE_CONFIG_SERIALIZED ), or using Sqlite3 wrapper in C#: