28 lines
882 B
Objective-C
28 lines
882 B
Objective-C
//
|
|
// FESDataProvider.m
|
|
// FestivalHelper
|
|
//
|
|
// Created by Hamo Hapic on 04/09/14.
|
|
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
|
//
|
|
|
|
#import "FESDataProvider.h"
|
|
|
|
@implementation FESDataProvider
|
|
|
|
+(void)getDataFromServerForUrl:(NSString *)urlString andProcessThemWith:(void (^)(NSData *data))block {
|
|
NSLog(@"Getting data from: %@" , urlString);
|
|
NSURL *url = [[NSURL alloc] initWithString:urlString];
|
|
[NSURLConnection sendAsynchronousRequest:[[NSURLRequest alloc] initWithURL:url] queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
|
|
if(connectionError) {
|
|
NSLog(@"Error getting %@ data from url: - %@", urlString, [connectionError localizedDescription]);
|
|
}
|
|
else {
|
|
NSLog(@"Parsing data.");
|
|
block(data);
|
|
}
|
|
}];
|
|
}
|
|
|
|
@end
|