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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:00:20+00:00 2026-05-27T20:00:20+00:00

I am working on my first iOS app, and have run in the first

  • 0

I am working on my first iOS app, and have run in the first snag I have not been able to find a good answer for.

The problem: I have a custom UIGestureRecognizer and have it all wired up correctly, and I can run code for each touch in the @selector after recognition. This has been fine for most things, but it’s a little too much input for others.

My goal: To make a timer that triggers at a specified interval to run the logic, and to be able to cancel this at the moment touches are cancelled.

Why I am asking here: There are a lot of possibilities for solutions, but none has stood out as the best to implement. So far it seems like

  • performSelector (and some variations on this)
  • NSThread
  • NSTimer
  • NSDate
  • Operation Queues
  • I think I found some others as well…

From all the research, some form of making a thread seems the route to go, but I am at a loss at which would work best for this situation.

An example of an implementation: an NSPoint is taken every 0.10 seconds, and the distance between the previous and current point is taken. [Taking the distance between every point was yielding very messy results].

The relevant code:

- (void)viewDidLoad {
 CUIVerticalSwipeHold *vSwipe =
 [[CUIVerticalSwipeHold alloc]
 initWithTarget:self 
 action:@selector(touchHoldMove:)];
 [self.view addGestureRecognizer:vSwipe];
 [vSwipe requireGestureRecognizerToFail:doubleTap];
}

...

- (IBAction)touchHoldMove:(UIGestureRecognizer *)sender {
     if (sender.state == UIGestureRecognizerStateEnded) {

     }

     if (sender.state == UIGestureRecognizerStateBegan) {

     }

     //other stuff to do goes here

}
  • 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-27T20:00:21+00:00Added an answer on May 27, 2026 at 8:00 pm

    Use an NSTimer

    Set it up like this:

        theTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(yourMethodThatYouWantRunEachTimeTheTimerFires) userInfo:nil repeats:YES];
    

    Then when you want to cancel it, do something like this:

        if ([theTimer isValid])
    {
        [theTimer invalidate];
    }
    

    Note that in the above example you would need to declare the “theTimer” instance of NSTimer where it will be available to both methods. In the above example the “0.5” means that the timer will fire twice a second. Adjust as needed.

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

Sidebar

Related Questions

I'm working on releasing my first app and I have been using a self
I am working on my first Objective-C app for iOS and am having an
I'm working on my first PHP project, and it's going well. I've been able
I've been working on my first XCode/iOS project and so far it's been an
I've searched for an answer to this question and have been unable to find
I've only been working on an iOS app now for a couple weeks so
I'm currently working on my first iOS application to run on the iPad, and
Short introduction Working on my first commercial iOS app, XCode 3.2 has proven to
I have been using the MGTwitterEngine and it is working fine on IOS 4.x,
I'm new to Core Data and I'm working on my first personal iOS app.

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.