On Jul 24, 2014, at 4:43 PM, Quincey Morris wrote: > On Jul 24, 2014, at 11:58 , edward taffel <etaf...@me.com> wrote: > >> NSStreamEventOpenCompleted = 1 << 0, >> >> a point of style? > > Supposition: > > It’s point of API self-documentation. The shift indicates that this is a bit > mask (or bit field) value, and hence that the enum’s members can usefully be > OR’ed together. Unshifted, the members would be whole values, and therefore > mutually exclusive. > > But I wouldn’t necessarily expect that the SDK is 100% consistent in this > regard.
Just look at the two typedefs in NSStream.h file for iOS 7. It's exactly where I got screwed up. The typedefs of NSStreamStatus and NSStreamEvent both use use NSUIntegers, but both declare them differently and one comes right after each other. typedef NS_ENUM(NSUInteger, NSStreamStatus) { NSStreamStatusNotOpen = 0, NSStreamStatusOpening = 1, NSStreamStatusOpen = 2, NSStreamStatusReading = 3, NSStreamStatusWriting = 4, NSStreamStatusAtEnd = 5, NSStreamStatusClosed = 6, NSStreamStatusError = 7 }; typedef NS_OPTIONS(NSUInteger, NSStreamEvent) { NSStreamEventNone = 0, NSStreamEventOpenCompleted = 1UL << 0, NSStreamEventHasBytesAvailable = 1UL << 1, NSStreamEventHasSpaceAvailable = 1UL << 2, NSStreamEventErrorOccurred = 1UL << 3, NSStreamEventEndEncountered = 1UL << 4 }; Reading the first typedef and switching back to code, I assumed that NSStreamEventEndEncountered was a uint, not a bit mask, since I eyeballed NSStreamStatus first. _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com