• 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
Re: 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]

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: Markus Spoettl <email@hidden>
  • Date: Mon, 2 Nov 2009 01:15:30 +0100

On Nov 2, 2009, at 12:51 AM, Jens Alfke wrote:
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.

True. I did one additional test in that I delayed opening the streams by 5 seconds (using performSelector:withObject:afterDelay:), giving the run loop enough time to release them if they were in fact auto- released (I know there's no guarantee they would actually be release in that period of time). The app doesn't crash and keeps working which indicates they are retained.


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.

Yes, the example releases the streams. They're removed from the run loop first, the author apparently forgot to close them though (not sure if that can have an effect on the retain count).


It appears that Apple already knows about this (see radar in comment), they just forgot to document it. How else would someone who writes example projects for the SDK know this specific function has this very special behavior - not that I know anything about who writes such examples.

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

References: 
 >Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that (From: Markus Spoettl <email@hidden>)
 >Re: Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that (From: Jens Alfke <email@hidden>)

  • Prev by Date: Commandline Tool Help - NSDistantObject and NSConnection
  • Next by Date: Re: Editing in a tableview without selecting
  • Previous by thread: Re: Does [NSNetService getInputStream:outputStream:] really return retain objects and where does it say that
  • Next by thread: Commandline Tool Help - NSDistantObject and NSConnection
  • Index(es):
    • Date
    • Thread