Guest User

Untitled

a guest
Feb 12th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. NSString *urlString;
  2. urlString = [NSString stringWithFormat:@"%@://%@:%@/",kHttp,_IP,_Port];
  3. NSURL *url = [NSURL URLWithString:urlString];
  4.  
  5. // Set authorization
  6. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
  7. [httpClient setAuthorizationHeaderWithUsername:_User password:_Pass];
  8.  
  9. NSURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"Info.htm" parameters:nil];
  10. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
  11. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  12. if ([self parseInfoLive:operation.responseString])
  13. _count_parsed++;
  14. if (_count_parsed == 2)
  15. [[NSNotificationCenter defaultCenter] postNotificationName:@"downloadsComplete" object:nil];
  16. }
  17. failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  18. NSLog(@"Error during connection: %@",error.description);
  19. [[NSNotificationCenter defaultCenter] postNotificationName:@"errorConnecting" object:nil];
  20. }];
  21. [operation start];
Add Comment
Please, Sign In to add comment