How to use NSScanner to parse .ics file

谁都会走 提交于 2019-12-04 13:52:09

问题


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

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

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

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

Please provide code examples..


回答1:


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



来源:https://stackoverflow.com/questions/5111919/how-to-use-nsscanner-to-parse-ics-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!