从 iPhone 应用程序导出日志
我的应用程序中的功能之一是日志,用户可以在其中添加日志条目。我想让用户导出这些数据。但是我不知道应该使用哪种格式。数据如下所示:
日期、距离、持续时间、最多四个类别名称。我想要的是,如果用户有 dropbox,则可以通过邮件发送它,或者使用 URL 方案通过 dropbox 打开它。
我读过有关 CSV 格式的内容,但我不知道这是否是一种好的文件格式?我主要关心的是用户不必拥有固定数量的类别(可以在 1-4 个类别之间)
One of the features in my application is a log where a user can add log entries. I want to make it possible to for the user to export this data. However I do not know which format I should use for this. The data looks like this:
A date, distance, duration, maximum four category names. What I want is to make it possible to send it on mail or open it with dropbox using the URL scheme if the user has dropbox.
I have read about CSV format but I don't know if that is a good file format? My main concern is that the user do not have to have a fixed number of categories (could be between 1-4 categories)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于要导出的数据列总体上是动态的,因此它将取决于用户的选择 - 这没有任何问题。
我认为 .csv 也适合这个目的 - 但你需要问自己......用户将如何处理数据?您可以提供多种文件导出格式或任何最适合用途的格式,具体取决于您的普通用户将如何使用它。
Seeing as the columns of data to be exported will be dynamic in total, it will depend on what the user selects - and there's nothing wrong with this.
I think .csv is fine for this purpose as well - but you need to ask yourself... what will the user be doing with the data? You could either offer multiple file export formats or whatever is the best-for-purpose format, depending on what your average user will do with it.
CSV(逗号分隔值)很简单(并且增加了很少的开销 - 逗号),但不是很灵活。例如,这非常适合导入到 MSFT Excel。
您应该考虑使用 XML(与 plist 所使用的基础格式相同),这是一种非常灵活的(如果您希望将来添加其他列,那么未来的证明)并且受良好支持的格式。
CSV (comma separated values) is simple (and adds very little overhead - the commas), but not terribly flexible. This is good for importing to MSFT Excel, for instance.
You should consider using XML (the same underlying format used for plists) which is a very flexible (future proof should you wish to add additional columns in the future) and well supported format.