I am working on a project where one of the requirements is to send and receive data using bitmasks. I have 12 bits (12 pieces of data) that I have to transmit the status of. I have an elementary understanding of bitmasks. Does anyone have a good example of using bitmasks with iOS to send and receive data? I am well versed on how to send data, I'm just not sure how to assemble and read the bitmask. Thanks.
Asked
Active
Viewed 61 times
0
-
More information is needed. In general values are generally obtained from bitmasks using logical ands `&` of a bitmak and as necessary shifting '>>' or '<<'. – zaph Oct 02 '15 at 17:46
1 Answers
1
It's really easy to manipulate true bitmasks in Swift 2.0: just make an OptionSetType. Nice example in the docs: https://developer.apple.com/library/ios/documentation/Swift/Reference/Swift_OptionSetType_Protocol/index.html

matt
- 515,959
- 87
- 875
- 1,141
-
And if you want to play with an _existing_ OptionSetType, pick something like UIViewAutoresizing. – matt Oct 02 '15 at 17:48
-
And of course modesty will never prevent me from suggesting that you just might try reading _my_ explanation: http://www.apeth.com/swiftBook/ch04.html#SECoptionsSets – matt Oct 02 '15 at 17:49