title: Is this usage of NSMutableString a memory leak?
body: <p>I'm currently using an instance variable that's an NSMutableString in a class which is a delegate for NSURLConnection. The variable is responsible for building a string of data that's returned from the delegate method:</p>
  
  <pre><code>- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data 
  </code></pre>
  
  <p>The string, 'foo', has a property set with retain on it. It is alloc'd in my classes init method very straight forward in this fashion:</p>
  
  <pre><code>dataString = [[NSMutableString alloc] init];
  </code></pre>
  
  <p>It is released in the classes dealloc method.</p>
  
  <p>In connection:didReceiveData:, I use the var like this:</p>
  
  <pre><code>    NSString *tmpString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
      [dataString appendString:tmpString];
      [tmpString release];
  </code></pre>
  
  <p>Now this is where things get tricky. Since the class where I set the NSURLConnection delegate is a singleton (it mainly handles NSURL* type calls), I need to becareful with how I re-use my objects. Therefor, in my connectionDidFinishLoading: class I have the following: </p>
  
  <pre><code>   // cache away data currently in dataString.
  [dataString release];
  dataString = [[NSMutableString alloc] init];
  </code></pre>
  
  <p>Does that strategy of handling my dataString make your eyes bleed? Am I leaking memory? What can I do that's smarter?</p>