Then the bug is somewhere in your changes. The only thing you should do is remove the retain calls. If you also remove the release calls, you will still have the memory leaks.

Here's what openStreams should look like:

- (void)openStreams {
  [inputStream setDelegate:self];
  [outputStream setDelegate:self];
  [inputStream scheduleInRunLoop:
      [NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
  [outputStream scheduleInRunLoop:
      [NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
  [inputStream open];
  [outputStream open];
}

Here's what closeStreams should look like:

- (void)closeStreams {
  [inputStream close];
  [outputStream close];
  [inputStream removeFromRunLoop:
      [NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
  [outputStream removeFromRunLoop:
      [NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
  [inputStream setDelegate:nil];
  [outputStream setDelegate:nil];
  [inputStream release];
  [outputStream release];
  inputStream = nil;
  outputStream = nil;
}

I have done exactly what you wrote above in a freshly dezipped CocoaEcho Project. Running it first with the retain and then without. It didn't work. This morning, I tried it again and it worked?!? I think I forgot to clean the build or something like that... Thanks for your help


Still, my question remains: Is there a rule of thumb for the memory management of object returned by reference? NSError and NSGradient autorelease their objects, NSNetService does not. Because the docs don't say anything about this (with the exception of the Error Handling Programming Guide), how should one know if an object should be retained or not?

Marco
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to