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


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

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