how to make serialized async tasks
<p>i want to run some operations task with <strong>completion</strong>  <strong>continuation- sequentially</strong> </p>

<p>for example  i want to execute <code>getSomethingsWithResultWithCompletion</code> method for 3 times  as serialized tasks (like op1 depend op2 , ... depen op N ) :</p>

<pre><code>[MFLayer getSomethingsWithResultWithCompletion:^(id  _Nullable response)Completion {

 // it will be run on another thread!** 
[MFRequestManager retrivesomeDataWithCompletion:^(id  _Nullable response1) {

 // it will be run on another thread!** 
  [MFRequestManager retriveAnothersomeDataWithInfo:response1 WithCompletion:^(id  _Nullable response2) {

      NSLog(@"Finished with Result : %@",response2);

 }];

 }];

}];
</code></pre>

<p><strong>Problem</strong></p>

<p>if <code>retrive methods</code> execute in another thread (like send a request with AFNetworking) i have a problem with serialize and another task will be start.</p>

<p>i have try With NSOperationQueue and Semaphore but still have a problem</p>

<p>i have implemented  something like this with <code>NSOperationQueue</code> and <code>NSOperation</code> but implementation of them have run on the same thread so all of task start sequentially so it's works fine.
<a href="https://github.com/mfarhand/operationQueueExample" rel="nofollow">operationQueueExample</a></p>