title: Objective C - Block Code not Executing Sequentially?
body: <p>I am trying to load data into the application as the cells come into view so that once they press the cell's accessory button it will have the data loaded.</p>
  
  <p>My problem is that I am using AFNetworking and I am using this block code:</p>
  
  <pre><code>[Request fullRequestWithBlock:^(NSArray *detailedReqFromWeb, NSError *error) {
          if (error) {
  
              [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:[error localizedDescription] delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"OK", nil), nil] show];
          } else {
  
              NSArray *objs = [NSArray arrayWithObjects: [detailedReqFromWeb objectAtIndex: 0], [detailedReqFromWeb objectAtIndex: 1], [detailedReqFromWeb objectAtIndex: 2], [detailedReqFromWeb objectAtIndex: 3], [detailedReqFromWeb objectAtIndex: 4], [detailedReqFromWeb objectAtIndex: 5], nil];
              NSArray *keys = [NSArray arrayWithObjects:@"Risk", @"Destination", @"Source", @"Customer", @"Subcategory", @"Deployment", nil];
  
              NSMutableDictionary *detailsforRequestDictionary = [[NSMutableDictionary alloc] initWithObjects:objs forKeys:keys];
  
              [request addEntriesFromDictionary: detailsforRequestDictionary];
  
              NSLog(@"%@ Finished Loading", [idNumbers objectAtIndex:row]);
              cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
  
          }
  
      } forID: [[idNumbers objectAtIndex:row] substringFromIndex:1]];
  </code></pre>
  
  <p>So basically, I am trying to change the accessory type from the indicator to the disclosure button once the data is loaded so then I can perform a segue to another view where the data that I loaded will be shown. </p>
  
  <p>My problem is that it is changing the cell.accessoryType to the button before it has finished loading. The debug NSLog actually outputs when it actually finishes loading.</p>
  
  <p>What is the best way to only enable the button when it's done loading? I am guessing the request is not being processed by the main thread. How come I be notified that the request has finished processing so I can switch accessoryTypes?</p>
  
  <p>Thanks!</p>