Created
October 28, 2013 20:01
-
-
Save Aquima/7203573 to your computer and use it in GitHub Desktop.
Ejemplo de como usar NSURLSession
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "WSConsult.h" | |
@interface WSConsult()<NSURLSessionDelegate> | |
@end | |
@implementation WSConsult | |
+(WSConsult *)sharedInstance { | |
static dispatch_once_t pred; | |
static WSConsult *shared = nil; | |
dispatch_once(&pred, ^{ | |
shared = [[WSConsult alloc] init]; | |
}); | |
return shared; | |
} | |
+(void)getInfoFacebook{ | |
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration]; | |
NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: nil delegateQueue: [NSOperationQueue mainQueue]]; | |
NSURL * url = [NSURL URLWithString:@"http://kodebinario.com/get"]; | |
NSURLSessionDataTask * dataTask = [defaultSession dataTaskWithURL:url | |
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { | |
if(error == nil) | |
{ | |
NSString * text = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]; | |
NSLog(@"Data = %@",text); | |
} | |
}]; | |
[dataTask resume]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment