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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:04:46+00:00 2026-05-25T06:04:46+00:00

1) I created a NSTimer on viewdidload #ifndef NDEBUG NSLog(@************In viewDidLoad method initializng timer

  • 0

1) I created a NSTimer on viewdidload

#ifndef NDEBUG
    NSLog(@"************In viewDidLoad method initializng timer [%@]",[NSThread currentThread]);
#endif
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(onTimerKicks:) userInfo:clues repeats:YES];

2) The selector call back performs some conditional logic (Play back time of a video) . The problem is every time the timer wakes up it calls the selector method twice for the same instance on the same thread !!! How do I know ? NS log statements printing thread details and debug.

- (void) onTimerKicks:(NSTimer *) timer
{

    if (currentPlaybackTime == 10) {

#ifndef NDEBUG
        NSLog(@"[%@] ************calling onTimerKicks:onAutoPageTimer from onTimer current playbacktime = %d", [NSThread currentThread], currentPlaybackTime);
#endif

    }
}

3) Here is the debug for one wake up of the timer

2011-08-30 19:11:51.759 MASLTales[7735:207] ************In viewDidLoad method initializng timer [<NSThread: 0x580f3a0>{name = (null), num = 1}]
2011-08-30 19:12:05.760 MASLTales[7735:207] [<NSThread: 0x580f3a0>{name = (null), num = 1}] ************ccalling onTimerKicks:onAutoPageTimer from onTimer current playbacktime = 10
2011-08-30 19:12:06.260 MASLTales[7735:207] [<NSThread: 0x580f3a0>{name = (null), num = 1}] ************ccalling onTimerKicks:onAutoPageTimer from onTimer current playbacktime = 10

Anybody knows why I see this message twice all the time ?
Thanks in advance.

  • 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-25T06:04:46+00:00Added an answer on May 25, 2026 at 6:04 am

    Actually its not calling the selector twice, it is calling selector continously because while initializing timer you have written repeats:YES];. But in your selector there is a conditional block which is true only for a 1 sec and your timer is firing selector for every half second. So its printing twice.

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

Sidebar

Related Questions

If I create a timer which never repeats [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(updateSystems) userInfo:nil repeats:NO];
I have created a NSTimer and call it every 15 seconds. Method that I
I create a timer with [NSTimer scheduledTimerWithTimerInterval:target:selector:...] from a background thread It seems the
I create an NSTimer : [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(createObject:) userInfo:nil repeats:YES]; and createObject: is
I create a timer in my ViewDidLoad method of my view-controller. NSMethodSignature *sgn =
I have created an app that uses NSTimer, which gets triggered each second. My
I am have created a timer where I convert the remaining time to a
I have problem with my timer. In my game view in viewDidLoad I have:
so here is the problem i have, i created two NSTimer objects and they
I have a NSTimer that I create when entering method - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary

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.