This is a bit basic; I am trying to retrieve http data for an iPhone app.
I have www.myhost.com/test.html that reads
<array><string>test</string><string>test2</string></array>
Then I have
NSURL *baseURL = [NSURLRLWithString:@"http://www.myhost.com/test.html"];
NSArray *array = [NSArray arrayWithContentsOfURL:baseURL];
NSLog(@"%@", [array description]);
Which keeps returning (null). What am I missing? Thanks!
It should probably be in a complete plist format (with doctype and all that)
The man page
easiest way to create a proper plist is with "Property List Editor.app"
on a side note: NSLog(@"%@", [array description]);
is the same as NSLog(@"%@", array);
The arrayWithContentsOfURL documentation clearly states that
The array representation at the location identified by aURL must contain only property list objects (NSString, NSData, NSArray, or NSDictionary objects).
That is, the kind of objects that you would obtain by calling the writeToURL:atomically method. The location written by this method can be used to initialize a new array with the class method arrayWithContentsOfURL:
or the instance method initWithContentsOfURL:
. Therefore, I suggest using these standard methods for writing and reading your arrays from an URL, instead of writing your own file and trying to read it by arrayWithContentsOfURL:
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With