On Oct 10, 2009, at 9:36 AM, DKJ wrote:

I've got an NSArray that I initialise with data from a plist stored on a remote webserver. I've been doing it like this:

NSURL *url = [NSURL URLWithString:@"http://www.server.com/ data.plist"];
        NSArray *myArray = [NSArray arrayWithContentsOfURL:url];

which has been working just fine so far.

But now I'm reading through the "URL Loading System" docs, and wondering if I should be using all the NSURLRequest stuff instead. It's more complicated, so are there any advantages it would have over what I'm doing now?


arrayWithContentsOfURL: is a blocking call. Typically, when working with data over networks, it's best to do things asynchronously.

When going the async route, you're going to get much better error- handling too. The call you're currently using will simply return nil upon any error. You then wouldn't know if the URL is bad, timeout occurred, file is bad, etc.

___________________________________________________________
Ricky A. Sharp         mailto:[email protected]
Instant Interactive(tm)   http://www.instantinteractive.com



_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to