Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 83133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:43:33+00:00 2026-05-10T21:43:33+00:00

I can follow most of Apple’s WiTap sample, but am sort of stumped on

  • 0

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.


thanks for the response. I am still puzzled a bit. Get it?

Basically, why?

Is this just a geeky way of passing an identifier? Each of those views have a tag #, why not just pass that, and toggle the state (up/down) from the view class?

Is this just a case of ‘this is how the person who wrote it did it’, or am I missing a crucial piece of the puzzle in that this is how I should also be structuring my code.

I would just want to pass a tag # and then have that tag decide what to do in a clearly readable function like toggleUpOrDownState or something.

This bitwise stuff always makes me feel stupid I guess, unless it is necessary, etc. Then I feel stupid but manage to muddle through somehow anyway. : )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:43:33+00:00Added an answer on May 10, 2026 at 9:43 pm

    Basically, [view tag] | 0x80 is setting the high bit in that value (so 00010011 would become 10010011) and [view tag] & 0x7f is removing it (10010011 -> 00010011).

    Take a look at the [AppController stream:handleEvent:] method. You’ll see this code:

            //We received a remote tap update, forward it to the appropriate view     if(b & 0x80)         [(TapView*)[_window viewWithTag:b & 0x7f] touchDown:YES];     else         [(TapView*)[_window viewWithTag:b] touchUp:YES]; 

    So, the receiver of the stream is checking for that high bit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 59k
  • Answers 59k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer There is a way to disassemble a function or a… May 11, 2026 at 9:04 am
  • added an answer You could try these two, I have seen success with… May 11, 2026 at 9:04 am
  • added an answer like this: print('-despc', filename) btw, switch -tiff can be useful… May 11, 2026 at 9:04 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.