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!
` at the end of every line. Could you please re-paste your code and use the preferred formatting technique? Please also [remove the tags](http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles) from the title. They are redundant. – jscs Jul 31 '12 at 20:14