• 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
Is NSStreamEvent a bitfield or not?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is NSStreamEvent a bitfield or not?


  • Subject: Is NSStreamEvent a bitfield or not?
  • From: "Sean McBride" <email@hidden>
  • Date: Mon, 1 Nov 2010 18:01:11 -0400
  • Organization: Rogue Research Inc.

Hi all,

I'm just playing with NSStream for the first time, and all the code and
docs I've seen have a switch in the implementation of
stream:handleEvent:, like:

 switch(eventCode) {
   case NSStreamEventHasBytesAvailable:
   ...

ex:

<http://developer.apple.com/library/mac/documentation/cocoa/Conceptual/
Streams/Articles/ReadingInputStreams.html#//apple_ref/doc/uid/
20002273-1001882>

Yet the docs also say this:

Stream Event Constants
One or more of these constants may be sent to the delegate as a bit
field in the second parameter of stream:handleEvent:.

typedef enum {
   NSStreamEventNone = 0,
   NSStreamEventOpenCompleted = 1 << 0,
   NSStreamEventHasBytesAvailable = 1 << 1,
   NSStreamEventHasSpaceAvailable = 1 << 2,
   NSStreamEventErrorOccurred = 1 << 3,
   NSStreamEventEndEncountered = 1 << 4
};

If these things can be bitwised ORed, why is all the code out there
'switch'ing?  I'm confused.

Thanks,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

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: Is NSStreamEvent a bitfield or not?
      • From: Andreas Mayer <email@hidden>
  • Prev by Date: Any way to get NSTextFieldCell to wrap AND truncate?
  • Next by Date: Re: Any way to get NSTextFieldCell to wrap AND truncate?
  • Previous by thread: Re: Any way to get NSTextFieldCell to wrap AND truncate?
  • Next by thread: Re: Is NSStreamEvent a bitfield or not?
  • Index(es):
    • Date
    • Thread