NSURL *URL = [NSURL URLWithString:@”http://www.raywenderlich.com/demos/weather_sample/weather.php?format=json“];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];

AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
op.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@”text/html”];
op.responseSerializer = [AFJSONResponseSerializer serializer];
[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@”JSON: %@”, responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@”Error: %@”, error);
[[NSOperationQueue mainQueue] addOperation:op];


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s