Re: Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that
Re: Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that
- Subject: Re: Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that
- From: Jens Alfke <email@hidden>
- Date: Sun, 1 Nov 2009 15:51:20 -0800
On Nov 1, 2009, at 1:30 PM, Markus Spoettl wrote:
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.
Yes; but that doesn't necessarily mean the streams will go away soon
if you don't retain them. An NSStream object is usually scheduled on a
runloop, which keeps a reference to it as long as its open, so I
believe it will stay around even if not explicitly retained by the app.
Sure enough the author of the example project believes what he says
because the project doesn't retain the streams anywhere.
Does it release the streams? That would be the true test. My belief is
that it can get away without retaining them, as long as it never
accesses them again after they close; but if it explicitly releases
them, it would crash.
That said, I think it's safer to keep your own references to the
stream objects by retaining and releasing them.
—Jens
_______________________________________________
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