If the network request itself is asynchronous, then joining the ready-made queue will definitely be asynchronous directly. Directly executing the next one cannot be directly queued for execution.
So you have two methods to handle it. One is to block with a signal, and the other is to call back the next operation after completion. In short, it is similar to
Then put all the operations into an operations array
Then
NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
//your request
// success in your request--> callback next operation
// fail in your request-->do something
}];
Signal blocking can also be used, but the efficiency will be compromised. It should be easy to understand when written like this, right?
Use NSOperationQueue
Create a
NSOperationQueue
,设置其maxConcurrentOperationCount
为1
so that they are executed sequentially.Okay, let me post the code
If the network request itself is asynchronous, then joining the ready-made queue will definitely be asynchronous directly. Directly executing the next one cannot be directly queued for execution.
So you have two methods to handle it. One is to block with a signal, and the other is to call back the next operation after completion. In short, it is similar to
Then put all the operations into an operations array
Then
Signal blocking can also be used, but the efficiency will be compromised. It should be easy to understand when written like this, right?