• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that


  • Subject: Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that
  • From: Markus Spoettl <email@hidden>
  • Date: Sun, 1 Nov 2009 22:30:15 +0100

Hi,

I'm puzzled by a comment in the WiTap iPhone SDK example project that I can't confirm through documentation or header comments. The method and comment is this (AppController.m line 214 onwards):

- (void) browserViewController:(BrowserViewController *)bvc didResolveInstance:(NSNetService *)netService
{
if (!netService) {
[self setup];
return;
}


// note the following method returns _inStream and _outStream with a retain count that the caller must eventually release
if (![netService getInputStream:&_inStream outputStream:&_outStream]) {
[self _showAlert:@"Failed connecting to server"];
return;
}


  [self openStreams];
}

Note the comment above "if (![netService getInputStream...".

The documentation doesn't back this assertion, neither does the header comment in NSNetServices.h. According to the memory management rules the method should return autoreleased streams.

Sure enough the author of the example project believes what he says because the project doesn't retain the streams anywhere. And surprisingly the project doesn't crash which if should at some point if the streams where auto-released - so they must be retained.

So, am I blind? I can't find where it says they are.

Looking a bit further the same kind of comment pops up in on other example too (Cocoa SimpleNetworkStream) where it also references a radar (rdar://problem/6868813), so this is known. Why not add a note to getInputStream:outputStream: then?

Regards
Markus
--
__________________________________________
Markus Spoettl

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: objectAtIndex
  • Next by Date: Re: Editing in a tableview without selecting
  • Previous by thread: Re: objectAtIndex
  • Next by thread: Re: Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that
  • Index(es):
    • Date
    • Thread