Advertisement
Guest User

Untitled

a guest
Oct 6th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. dispatch_queue_t myQueue = dispatch_queue_create("get Token", NULL);
  2. dispatch_async(myQueue, ^{
  3. NSURL *myURL = [NSURL URLWithString:@"http://test.myServer.am/api/authentication/Login?username=test&password=test"];
  4.  
  5. NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:myURL];
  6. [request setHTTPMethod:@"GET"];
  7. [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
  8. NSURLResponse *response = nil;
  9. NSError *myErr;
  10. NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&myErr];
  11.  
  12. NSMutableArray *_objects = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&myErr];
  13. dispatch_async(dispatch_get_main_queue(), ^{
  14.  
  15. // call more APIs after receiving token
  16.  
  17. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement