开发者

Using DB or XML Parsing for an iPhone App?

开发者 https://www.devze.com 2023-01-19 23:37 出处:网络
For a products catalogu开发者_Python百科e app on iphone which approach is more efficient? Using sqllite db or directly parsing online from xml without db?Small amounts of data can be loaded as XML dir

For a products catalogu开发者_Python百科e app on iphone which approach is more efficient? Using sqllite db or directly parsing online from xml without db?


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.)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消