Queueing and Handling multiple requests on iphone
<p>In my application, I'm using NSOperationQueue and NSInvocationOperation objects to execute all the operations. I have multiple queues in my application and I am using KVO "isFinished" on call of which I am performing the next operation on main thread. </p>

<p>The problem is: whenever I perform two operations one after another my application crashes saying: </p>

<pre><code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '&lt;myViewController: 0x481b200&gt;: An     -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
Key path: isFinished
Observed object: &lt;NSInvocationOperation: 0x45d9ea0&gt;
Change: {
 kind = 1;
}
Context: 0x0'
</code></pre>

<p>My general code is as follows:</p>

<pre><code>operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(somemethod) object:nil];

[operation addObserver:self forKeyPath:@"isFinished" options:0 context:nil];

[operationQueue addOperation:operation];
[operation release];    

- (void)observeValueForKeyPath:(NSString *)keyPath 
                        ofObject:(id)object 
                           change:(NSDictionary *)change 
                         context:(void *)context
{
   if([keyPath isEqual:@"isFinished"] &amp;&amp; operation == object)
 {


    [operation removeObserver:self forKeyPath:@"isFinished"];
     [self performSelectorOnMainThread:@selector(newerPostLoadingNumberOfUdates) withObject:nil waitUntilDone:YES];

 } 


 else 
 {
     [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
 }
}
</code></pre>

<p>I want to know wheather what is the best practice to enqueue operations that are requested and execute them accordingly?</p>

<p>Thanx in advance.</p>
