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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:30:25+00:00 2026-06-08T19:30:25+00:00

I am starting a timer with view did load – (void)viewDidLoad { [super viewDidLoad];

  • 0

I am starting a timer with view did load

– (void)viewDidLoad
{
[super viewDidLoad];
locationManager.delegate = self;

[NSTimer scheduledTimerWithTimeInterval: 10.0 //interval here must be a float
target: self
selector:@selector(onTick:)

userInfo: nil repeats:YES];

}

then i have my timer method:

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

[locationManager startUpdatingLocation];

}

then the location manager is called since its a delegate:

-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

NSLog(@”made it to location manager”);

NSTimeInterval timePassedSinceLastLocationUpdate = fabs([oldLocation.timestamp timeIntervalSinceNow]);

NSLog(@”update time: %f”, timePassedSinceLastLocationUpdate);

NSLog(@”————–“);

//other stuff happens
[locationManager stopUpdatingLocation];
}


However, the NSLOG that is shown is this:

2012-07-31 13:02:28.092 round5[1713:f803] made it to location manager
2012-07-31 13:02:28.095 round5[1713:f803] update time: 0.000000
2012-07-31 13:02:28.095 round5[1713:f803] ————–
2012-07-31 13:02:33.298 round5[1713:f803] made it to location manager
2012-07-31 13:02:33.298 round5[1713:f803] update time: 5.222202
2012-07-31 13:02:33.300 round5[1713:f803] ————–
2012-07-31 13:02:44.086 round5[1713:f803] made it to location manager
2012-07-31 13:02:44.086 round5[1713:f803] update time: 15.986345
2012-07-31 13:02:44.087 round5[1713:f803] ————–
2012-07-31 13:02:53.297 round5[1713:f803] made it to location manager
2012-07-31 13:02:53.302 round5[1713:f803] update time: 9.217123
2012-07-31 13:02:53.303 round5[1713:f803] ————–
2012-07-31 13:03:04.096 round5[1713:f803] made it to location manager
2012-07-31 13:03:04.097 round5[1713:f803] update time: 20.007919
2012-07-31 13:03:04.098 round5[1713:f803] ————–
2012-07-31 13:03:13.297 round5[1713:f803] made it to location manager
2012-07-31 13:03:13.298 round5[1713:f803] update time: 9.202388
2012-07-31 13:03:13.300 round5[1713:f803] ————–
2012-07-31 13:03:24.111 round5[1713:f803] made it to location manager
2012-07-31 13:03:24.112 round5[1713:f803] update time: 20.012550
2012-07-31 13:03:24.113 round5[1713:f803] ————–

as you can see towards the bottom the pattern normalizes and it either reads ~10 seconds (which is right, because thats what the interval is set to and compared against the system clock)

and 20… which…i don’t know where it comes from.

I guess my question is “Why isn’t it reading 10 seconds all the time; why does it double the NStimer value?”

thanks a lot!

  • 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-08T19:30:28+00:00Added an answer on June 8, 2026 at 7:30 pm

    You have two mistakes here. First, you shouldn’t call startUpdatingLocation repeatedly. You should call it one time to start requesting updates as they’re available (you should then call stopUpdatingLocation when you don’t need updates anymore). Your second mistake is believing that calling startUpdatingLocation will always return you a new location. You’re not checking the last time your NSTimer ran. You’re checking the last time CLLocationManager updated the location (oldLocation.timestamp). This can be any arbitrary amount of time. It may not have been able to get an update when you asked for it last time. It may have updated at times you didn’t ask for it.

    Read over the Location Awareness Programming Guide. It explains how to request updates and when to request updates. Generally you turn it on and tell the system how accurate you want your updates. You then let the system call you when things change. You do not repeatedly ask for location updates.

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

Sidebar

Related Questions

I have an application in which I am starting a timer for two task:
I am starting the Timertask in Oncreate of an Activity. The timer task listens
Starting off with a default View based application I create a new view (ViewToDisplay,
Problem is location manager is not updating location. The (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLoc fromLocation:(CLLocation
NSTimer is pausing a while an then again it is starting when UIGesture action
Is there any attribute associated with the starting time I can get from the
I am using today's timetable plugin on my website. Problem is, starting time is
I have 100 text files which contains time series starting and ending at different
I'm starting a development to support real-time gaming. I need to support collaborative game
I am just starting to learn Ruby (first time programming), and have a basic

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.