Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that
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