I want to perform 2 requests and send a notification at the end. My code to check a sequence of the operations:
AFHTTPRequestOperation *operation1 = ...;
AFHTTPRequestOperation *operation2 = ...;
[operation1 setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"asdf");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
[operation2 setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"asdf");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
NSBlockOperation *operation3 = [NSBlockOperation blockOperationWithBlock:^{
NSLog(@"123");
}];
NSArray *operationArray = @[operation1, operation2, operation3];
for (int i = 1; i < operationArray.count; i++) {
NSOperation *op = operationArray[i];
[op addDependency:operationArray[i - 1]];
}
[queue addOperations:ops waitUntilFinished:NO];
I expect the following console log:
asdf
asdf
123
But the actual result is:
asdf
123
asdf
WHY?