For iOS 7+ and OS X 10.9+ use:
NSURLSession *aSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[[aSession dataTaskWithURL:[NSURL URLWithString:@"http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (((NSHTTPURLResponse *)response).statusCode == 200) {
if (data) {
NSString *contentOfURL = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", contentOfURL);
}
}
}] resume];
For earlier versions use:
[NSURLConnection sendAsynchronousRequest:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"]] queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (((NSHTTPURLResponse *)response).statusCode == 200) {
if (data) {
NSString *contentOfURL = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", contentOfURL);
}
}
}];
If you are looking for an easier to implement solution take a look at this link