title: Cocoa - Return information from NSOperation
body: <p>I have an IPhone app that uses webservices to get data from a server.  I'm putting each call to the webservice in a NSOperation subclass so that it can be threaded.  My question is, what is the recommended way to pass back information from a completed NSOperation subclass.  I'm currently sending a NSNotification at the end of my main method and any code that is waiting for the NSOperation to complete, subscribes to the notification.  And then I will use the object part of NSNotificationWithName:Object: to pass information back from the operation.</p>
  
  <p>I wasn't sure if there was a better way to do this.  I have heard of Key Value Coding and then I could use Key Value Observing to detect when the the isFinished property for the operation is changed, but I'm not sure what the best practice is.  </p>
  
  <p>I'm also trying to ensure that my application is thread safe, which I assume wouldn't be an issue as long as a my notification was sent out at the end of the main method thus the object in the notification would no longer be used in the thread since it will end.</p>
  
  <p>Finally, I am calling the notification like so:</p>
  
  <pre><code>[[NSNotificationCenter defaultCenter] performSelectorOnMainThread:@selector(postNotification:) withObject:[NSNotification notificationWithName:@"notificationName" object:dataObject] waitUntilDone:NO];
  </code></pre>