Friday, 21 June 2013

Fetch data from NSURL synchronously.

- (void)fetchDataSynchronouslyFromURL:(NSString*)urlStr
{
    NSString* serverUrl = urlStr;
    NSData *serverData = [NSData dataWithContentsOfURL:[NSURL URLWithString:serverUrl]];
    NSError* error = nil;
    id serverResponse = [NSJSONSerialization JSONObjectWithData:serverData options:kNilOptions error:&error];
    NSLog(@"Server response:%@",serverResponse);

}

No comments:

Post a Comment