Morgan Wilde
Morgan Wilde

Reputation: 17303

Wait for NSData dataWithContentsOfURL: to finish loading, and then

I have the following:

NSURL *apiURL = [NSURL URLWithString:apiURLString];
NSData *apiResult = [NSData dataWithContentsOfURL:apiURL];

How do I fire some code only after the loading is complete? In case it helps, the code I'm trying to execute at that point is a NSNotificationCenter notification.

Upvotes: 2

Views: 1062

Answers (1)

Stefan Arentz
Stefan Arentz

Reputation: 34945

The dataWithContentsOfURL method blocks until it has finished loading the data. So you can just add your code at the end of the snippet you showed.

Upvotes: 6

Related Questions