如何使用NSScanner解析.ics文件 [英] How to use NSScanner to parse .ics file

查看:217
本文介绍了如何使用NSScanner解析.ics文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何使用NSScanner解析一个ics文件? (Iphone应用程序)

Could someone please show how i could parse a ics file using NSScanner? (Iphone App)

例如:如果.ics文件位于此URL http://www.ibz.com/data/12345.ics (不是真正的网址!!!)

e.g: if the .ics file was at this URL http://www.ibz.com/data/12345.ics (not a real URL!!!)


  1. 我如何首先将.ics
    文件保存到我的iphone应用程序

  1. How would i firstly save the .ics file into my iphone app

然后如何我使用NSScanner解析
.ics文件?

and then secondly how would i parse the .ics file using NSScanner??

请提供代码示例..

推荐答案

完全做得很好的代码示例将非常广泛,并且SO不适合大型示例应用程序。考虑到这一点,一般的解决方案是:

Code examples to do this completely and well would be quite extensive, and SO isn't the place for large sample applications. With that in mind, the general solutions would be:


  1. 使用 NSURLRequest NSURLConnection 获取HTTP连接以下载文件;将其存储为NSURLConnection委托调用期间构建的NSData对象。一旦完全下载,将其转换为NSString进行解析。 URL加载系统编程指南有很多例子 - 查找NSURLConnection和异步请求。

  2. 解析.ics文件(此时可用作一个NSString),你首先需要弄清楚文件的预期格式。 维基百科似乎有几个例子说明.ics文件如何存储数据。基本上你会想要通过扫描由文件格式使用的各种分隔符分隔的字符串(看起来主要是冒号)。

  1. Use a NSURLRequest and NSURLConnection to get an HTTP connection to download the file; store it as an NSData object built during delegate calls from the NSURLConnection. Once it's completely downloaded, convert it to an NSString for parsing. The URL Loading System Programming Guide has a number of examples - look for NSURLConnection and asynchronous requests.
  2. To parse the .ics file (which at this point is available as an NSString), you'll first need to figure out the expected format of the file. Wikipedia seems to have a couple examples of how .ics files store data. Basically you'll want to go through and scan strings separated by the various separators the file format uses (looks to be mostly colons).

如果你有更具体的问题,你可能会得到更具体的答案 - 试一试,如果你遇到困难就问更多问题!

If you have more specific questions, you'll probably get much more specific answers - give it a shot and ask more if you get stuck!

这篇关于如何使用NSScanner解析.ics文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆