对 iPhone 应用程序使用 DB 或 XML 解析?
对于 iPhone 上的产品目录应用程序,哪种方法更有效?使用sqllite db还是直接从xml在线解析而不使用db?
For a products catalogue app on iphone which approach is more efficient? Using sqllite db or directly parsing online from xml without db?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
少量数据可以作为 XML 直接加载到内存中。因此,XML 就可以了。当使用大量数据时,数据库将是更好的选择,但它会降低速度,因为它需要将数据读/写到存储中。
对于iPhone应用程序和其他手机应用程序,内存之间的区别并且存储空间往往很小。不幸的是,要让应用程序理解 XML 文件,它必须在 DOM 模型中加载 XML。这将消耗大约 XML 大小的额外内存。因此XML不适合大量数据。 (或巨大的记录。)
如果您有多达 50 种产品,则剩余的产品有利于 XML。超过 50,你最好使用 sqllite。
XML 的另一个好处是您需要显式保存回存储以更新您的更改。对于数据库,对数据的任何更新往往都是直接完成的。因此,使用数据库来消除错误会遇到更多问题。然而,使用 XML,如果应用程序崩溃,您的更改将会丢失。就我个人而言,我更喜欢它只根据我的命令显式更新数据,因此我更喜欢 XML。 (但不适用于大量数据。)
Small amounts of data can be loaded as XML directly into memory. Thus, XML would do just fine. When using a large amount of data, a database would be a better option, but it will decrease speed simply because it needs to read/write the data to storage.
With iPhone apps and other mobile phone apps, the difference between memory and storage tends to be very small. Unfortunately, for an app to understand an XML file, it must load the XML in a DOM model. This will eat up additional memory of about the size of the XML. Thus XML is not suitable for large amounts of data. (Or huge records.)
If you have up to 50 products, the balance is in favor for XML. Over 50 and you're better off with sqllite.
An added bonus of XML is that you need to explicitly save back to storage to update your changes. With databases, any updates to the data tends to be done directly. Thus, with a database you have a bit more problems undoing any errors. However, with XML your changes will be lost if your application crashes. Personally, I prefer it to only update data explicitly on my command, thus I would prefer XML. (But not for large amounts of data.)
将您的产品添加到 sqllite,并在每次异步启动时仅将更改/新添加的产品更新到数据库。
根据数据库中的数据渲染视图。
Add your products to sqllite and update only changed/newly added products to the db at every launch asynchronously.
Render your View from the data in DB.