Guest User

Untitled

a guest
Sep 15th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. AFNetworking - Why does the asynchronous XML operation not fire and the loop runs infinitely?
  2. - (void)fetchActiveUser:(NSString*)username withPassword:(NSString *)password {
  3.  
  4. [self setAuthorizationHeaderWithUsername:username password:password];
  5.  
  6. // SETS FLAG that we are performing a request
  7. fetchModeActive = TRUE;
  8.  
  9. [self getPath:kTLActiveUserURI parameters:nil success:^(AFHTTPRequestOperation
  10. *operation, id responseObject) {
  11.  
  12. if ([responseObject isKindOfClass:[NSXMLParser class]]) {
  13. TLPersonParser *personParser = [[TLPersonParser alloc]
  14. initWithParser:responseObject];
  15.  
  16. [personParser setDelegate: self];
  17. [personParser parsePeople];
  18.  
  19. [personParser release];
  20.  
  21. }
  22. // handle stuff here.
  23. NSLog(@"Success!");
  24. fetchModeActive = FALSE;
  25. [[NSNotificationCenter defaultCenter]
  26. postNotificationName:kTLFetchedActiveUserNotification object:nil];
  27.  
  28.  
  29. }
  30. failure:^(__unused AFHTTPRequestOperation *operation, NSError *error) {
  31. NSLog(@"Failure.");
  32. fetchModeActive = FALSE;
  33. [[NSNotificationCenter defaultCenter]
  34. postNotificationName:kTLFetchedActiveUserNotification object:error];
  35. }];
  36.  
  37.  
  38. while(self.fetchModeActive) {
  39. // WHY DOES THIS RUN INFINITELY?
  40. // Both above Success: & Failure: blocks set fetchModeActive = FALSE
  41. // when complete
  42. NSLog(@"fetching....");
  43. }
  44.  
  45. }
Add Comment
Please, Sign In to add comment