title: Storing a parameter value to be returned later in delegate callback
body: <p>I have a singleton class and a protocol defined as below. (Simplified)</p>
  
  <pre><code>@protocol ClassADelegate &lt;NSObject&gt;
  
  - (void) classADelegateDidFinishSomething:(BOOL) aBool;
  
  @end
  
  
  @interface ClassA : NSObject
  
  @property (nonatomic, weak) id&lt;ClassADelegate&gt; delegate;
  
  + (ClassA *) shared;
  - (void) methodA:(BOOL) aBool;
  
  @end
  </code></pre>
  
  <p>The <code>methodA</code> method causes a chain of asynchronous callbacks internally and finally in a private method needs to call the delegate method like the following way.</p>
  
  <pre><code>if (self.delegate)
  {
      [self.delegate classADelegateDidFinishSomething:BOOL_FROM_methodA];
  }
  </code></pre>
  
  <p>Now <code>BOOL_FROM_methodA</code> in the above method must be the same as the <code>aBool</code> in the <code>methodA</code> method. So I have to store the value of the <code>aBool</code> somewhere. Lets say I store it in a private variable <code>_aBool</code> like the following and later using this to call the delegate method.</p>
  
  <pre><code>- (void) classMethodA:(BOOL) aBool
  {
      _aBool = aBool;
      ...
  }
  
  - (void) aPrivateMethod
  {
      ....
  
      if (self.delegate)
      {
          [self.delegate classADelegateDidFinishSomething:_aBool];
      }
  }
  </code></pre>
  
  <p>This solves the problem if it was guaranteed that no further calls to <code>classMethodA</code> is done before the delegate method is called. But imagine the following situation.</p>
  
  <pre><code>[[ClassA shared] methodA:YES];
  [[ClassA shared] methodA:NO];
  </code></pre>
  
  <p>For the above code, both of the <code>classADelegateDidFinishSomething</code> callbacks will have <code>NO</code> as their parameter value, even though the 1st <code>methodA</code> call has <code>YES</code> as its parameter.</p>
  
  <p>I would like to get an elegant solution to the problem without refactoring most of my code.</p>