开发者

Best format to receive data [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

What's the best alternative to read data of any kind in my iphone app ?

I want my client to be able to pass me the data for me to include in the app and read it easily.

What's best ?, XML ?, plist ?, other format ?, I'm not very informed in the matter.

开发者_JAVA百科

Thanks.


This depends on your use case.

If plist fits your data well just use it, access to your data is very simple this way.

But you can also use XML if your data structure fits this better or even binary data if it fits best to the data.


I definitely advocate XML.

"What is that?" You ask?

Because the iPhone NSXMLParser class gives you a single call:

- (id)initWithContentsOfURL:(NSURL *)url

Which is used to read the XML Document over an HTTP connection, into the parser object, allowing you to call a few other simple calls to itterate and parse the data from the XML document.

It then automatically parses the object, and gives you data back via. a few NSXMLParserDelegate calls.


If you are dealing with data that feel more like a document, XML is probably best. Generally, though, for programmatic data exchange, I think that JSON is way easier to deal with. It's less ambiguous, and tends to be more straightforward to unserialize as a native data type.


If the dataset is small-medium in size and the program sending it is on Mac OS X or iOS, your best bet is a plist. If you need OS interoperability you should try some other serialized format such as XML or even CSV (comma-separated values). For large datasets, a SQLite database might be a good choice.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜