Download a .plist file
Given I uploaded a .plist file to my online website (located at, dunno, www.example.com/data.plist), how do I download that .plist fi开发者_JAVA技巧le to my iPhone application and read it successfully?
NSURL* url = [NSURL URLWithString:@"http://www.example.com/data.plist"];
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:url];
Simplest way is to use the NSDictionary
method initWithContentsOfURL:
- this will download the plist specified by URL and build a dictionary from it in one go. Be advised it is a blocking call, for other options and how to avoid blocking start with the documentation for initWithContentsOfURL:
and explore.
精彩评论