Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dispatch_queue_t myQueue = dispatch_queue_create("get Token", NULL);
- dispatch_async(myQueue, ^{
- NSURL *myURL = [NSURL URLWithString:@"http://test.myServer.am/api/authentication/Login?username=test&password=test"];
- NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:myURL];
- [request setHTTPMethod:@"GET"];
- [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
- NSURLResponse *response = nil;
- NSError *myErr;
- NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&myErr];
- NSMutableArray *_objects = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&myErr];
- dispatch_async(dispatch_get_main_queue(), ^{
- // call more APIs after receiving token
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement