Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use NSScanner to parse .ics file

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

like image 300
Ibz Avatar asked Feb 24 '11 23:02

Ibz


1 Answers

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!

like image 141
Tim Avatar answered Nov 03 '22 12:11

Tim