Re: Is NSStreamEvent a bitfield or not?

2010-11-02 Thread Andreas Mayer

Am 01.11.2010 um 23:01 schrieb Sean McBride:

 I'm just playing with NSStream for the first time,

Me too. :)

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

Good question. My test application seems to work fine with switch statements. 
Maybe the documentation is incorrect?

The Stream Programming Guide says in Handling Stream Events:

More importantly, once the stream object has been opened, it keeps sending 
stream:handleEvent: messages to its delegate until it encounters the end of the 
stream. These messages include a parameter with an NSStreamEvent constant that 
indicates the type of event.

This seems to indicate that only a single constant value is passed, instead of 
a bit field.


Andreas___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Is NSStreamEvent a bitfield or not?

2010-11-01 Thread Sean McBride
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 s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com