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 6553439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:34:55+00:00 2026-05-25T12:34:55+00:00

Let me first write the code and then explain the problem -(void)touchesBegan:(NSSet*)touches withEvent(UIEvent*)event{ 1:

  • 0

Let me first write the code and then explain the problem

-(void)touchesBegan:(NSSet*)touches withEvent(UIEvent*)event{

    1: NSUInteger numTaps=[[touches anyObject] tapCount];
    2: NSString *labelText=[NSString stringWithFormat:@"Number of counts %d",
                                                                    numTaps];
    3: self.tapLabel.Text=labelText;
    4: if (numTaps==1)
    5: NSLog(@"Number of taps is 1");
}

Now, as you can see I assign tapCount value to numTaps in line 1. And in line 3 depending on the tap count my label shows number of counts 1,2,3,4….n. But then in line 4 I check if numTaps equals 1. Here comes the weird stuff. No matter how many taps a touch has the command in line 5 is always executed. So it seems like numTaps is always 1. But how come in line 2 namTaps is not always one. I’m sure I’m missing something there but can’t figure out what.

  • 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. Editorial Team
    Editorial Team
    2026-05-25T12:34:56+00:00Added an answer on May 25, 2026 at 12:34 pm

    From what I can see it may be, that you’ve forgot some ; after a lot of spaces in line 4, so it’s place in invisible area of the screen(at least if you don’t scroll to there). Try to put line 5 inside {} block like so

    4: if (numTaps==1){
    5:     NSLog(@"Number of taps is 1");
    6: }
    

    It’s always good practice to put the if block inside braces, even if you have only one line of code inside. Can avoid many bugs.
    Other possibility is that you’ve put single = in the if clause.(Happens a lot to me).

    4: if (numTaps=1)
    

    That actually assign 1 to numTaps variable so when the code goes one it is 1 inside.

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

Sidebar

Related Questions

Let me first put the code snippets here. I am just using the ASP.NET
First let me explain how I currently handle validation, say, for an IPv4 address:
I've got a strange problem. Let me first describe my situation: Webserver01 (Webapplication, SQL,
Let me first describe my goal: I have created an object with 3 properties:
First let me say that I really feel directionless on this question. I am
First let me say I have read this useful article thoroughly and am using
First let me state that, despite being a fairly new practitioner of TDD, I'm
First let me tell you what I want to achieve. I want a layout
First let me say that I did see this article: How to remove AspxAutoDetectCookieSupport
Let me state first: I know that any user that wants to run a

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.