title: Waiting for methods to finish in iOS
body: <p>I have two classes Controller and Connector in objective c. The Controller asks the Connector to build up a connection to a webservice to get some data. The connection itself is implemented with a delegate. This delegate gets a method call if the data arrived. I set the delegate to be the Connector itself. 
  My problem is that I want the Controller to call a method on the Connector and this method immediately returns the data. This is without delegation.
  I tried out Multithreading and waiting in the Controller, but I only could find multithreading for a single method:</p>
  
  <pre><code>[NSThread detachNewThreadSelector:@selector(myMethod) toTarget:myClass withObject:nil];
  </code></pre>
  
  <p>Multithreading for a single method does not work, because the delegate method in the Connector can't be called, because the whole Connector class is not threaded. Can anyone help me how to solve this?</p>
  
  <p>EDIT: I add the code where I call the connector method (this is code from the controller):</p>
  
  <pre><code>_data = nil;
  dispatch_queue_t myQueue = dispatch_queue_create("my queue", NULL);
  dispatch_async(myQueue, ^{
      _data = [_soapConnector startRequestWithSOAPMessage:soapMessage];
  });
  
  while(!_data){
      NSLog(@"waiting");
  }
  //data arrived successfully here so we can manipulate it
  </code></pre>