title: Call back style
body: <p>I am writing an iPhone application which in numerous places needs to perform non HTTP or FTP networking of a very simple request response type.</p>
  
  <p>I've wrapped all this up into a SimpleQuery class that integrates with the run loop. </p>
  
  <pre><code>SimpleQuery *lookup = [[SimpleQuery alloc] init];
  [lookup setDelegate:self];
  [lookup doQueryToHost:queryServer port:queryPort query:queryString ];   
  </code></pre>
  
  <p>As you can see the calling object sets itself as a delegate. When the results are complete it then calls a method on the delegate with the results.</p>
  
  <pre><code>[delegate simpleQueryResult:resultString simpleQuery:self];             
  </code></pre>
  
  <p>I am now in a position where I have a user of SimpleQuery that has two types of query so I need to extend SimpleQuery to support this.</p>
  
  <p>I can think of two sensible ways of doing this.</p>
  
  <p>Firstly passing a selector into doQueryString, or a seperate doQueryStringWithSelector.</p>
  
  <pre><code>[lookup doQueryToHost:queryServer port:queryPort query:queryString selector:@SEL ]; 
  </code></pre>
  
  <p>Secondly passing a tag into doQueryString so that when the delegate is called it can query the tag, as the simpleQuery is passed, to find out what the results are for.</p>
  
  <pre><code>[lookup doQueryToHost:queryServer port:queryPort query:queryString withTag:tag ];
  </code></pre>
  
  <p>I'm just wondering which is best from a coding style perspective, the first seems simpler but tagging seems more in keeping with the iPhone SDK and Interface Builder</p>