I can follow most of Apple's WiTap sample, but am sort of stumped on this bit in the send method:
- (void) send:(const uint8_t)message
{
if (_outStream && [_outStream hasSpaceAvailable])
if([_outStream write:(const uint8_t *)&message maxLength:sizeof(const uint8_t)] == -1)
[self _showAlert:@"Failed sending data to peer"];
}
- (void) activateView:(TapView*)view
{
NSLog(@"ACTIVATE TAG: %d", [view tag]);
//[self send:[view tag] | 0x80];
[self send:[view tag]];
}
- (void) deactivateView:(TapView*)view
{
NSLog(@"DEACTIVATE TAG: %d", [view tag]);
//[self send:[view tag] & 0x7f];
[self send:[view tag]];
}
Note that I have changed the send: argument to just the tag of the views, which are numbered 1-9. Originally the code had the bitwise AND and OR adjustments.
WHY?
I get the fact that the send method needs a uint8_t
, but is that why the bitwise stuff is there? To turn a NSInteger into a unint8_t?
The code doesn't work with my changes above. It will log fine and visually the client will function correctly, but the messages aren't being sent/received correctly from client to client.
Can someone explain in small words what the bitwise stuff is doing? Or am I correct?
Thanks! This is my first question to SO so please be kind.