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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:50:37+00:00 2026-06-08T06:50:37+00:00

in my application,I have implemented NSTimer to count time.I have swipe detection and when

  • 0

in my application,I have implemented NSTimer to count time.I have swipe detection and when
the user swipes on the screen,animation runs continuously.my question is when I swipe
on the screen(left/right continuously) NSTimer slows down.
can anybody tell me how to solve this problem?

//code

    gameTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/100
                                                          target:self
                                                        selector:@selector(updateGameTimer)
                                                        userInfo:nil
                                                        repeats:YES];

    -(void)updateGameTimer
    {
        counter++;
        tick++;
        if(tick==100){
            tick = 0;
            seconds += 1;
        }
        if(counter==100){
            counter = 0;
        }
        timerLabel.text = [NSString stringWithFormat:@"%i.%02d",seconds,counter];
    } 


//swipe detection

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    [super touchesMoved:touches withEvent:event];

    UITouch *touch = [touches anyObject];
    //CGPoint curPt = [touch locationInView:self.view];    
    CGPoint newLocation = [touch locationInView:self.view];
    CGPoint oldLocation = [touch previousLocationInView:self.view];
    gameView.multipleTouchEnabled = true;

    if(newLocation.x-oldLocation.x>0){
        swipe_direction = 1;
        //NSLog(@"left");
    }
    else{
        swipe_direction = 2;
        //NSLog(@"right");

    }

    if(swipe_direction==1){
        //animate images
        //play sound effect
    }
    else if(swipe_direction==2){
       //animate images
       //play sound effect
    }

}
  • 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-06-08T06:50:40+00:00Added an answer on June 8, 2026 at 6:50 am

    From the NSTimer documentation…

    A timer is not a real-time mechanism; it fires only when one of the
    run loop modes to which the timer has been added is running and able
    to check if the timer’s firing time has passed. Because of the various
    input sources a typical run loop manages, the effective resolution of
    the time interval for a timer is limited to on the order of 50-100
    milliseconds. If a timer’s firing time occurs during a long callout or
    while the run loop is in a mode that is not monitoring the timer, the
    timer does not fire until the next time the run loop checks the timer.
    Therefore, the actual time at which the timer fires potentially can be
    a significant period of time after the scheduled firing time.

    Your timer resolution is 10 milliseconds, so if the run loop doesn’t not complete quickly enough (under 10 milliseconds), you’ll start to notice a lag between real-time, and your counters.

    If you are implementing a game, devs will generally try to disassociate from the CPU or clock speed.

    Take a look at this answer

    or take a look at how a framework like cocos2d implements its own scheduler.

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

Sidebar

Related Questions

I have implemented an application for get the images from external storage when user
In my application I have implemented a method to get favourits of particular user.
I am making on application in which user have to select the time, example
I would like to handle screen orientation in a sample application.I have implemented code
I am writing a web application and have just implemented that a user can
We have a vb.net application where we have implemented multithreading. We determined that we
I have implemented an application using jQuery on PhoneGap. In that I'm using a
I have implemented an application with multiple check boxes with multiple layouts.I am invisible
I have implemented an application for modify the xml layout with some properties. I
I have implemented lucene for my application and it works very well unless you

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.