Reputation: 1
I'm trying to find a solution to a problem I just stumbled upon. Tried to search for it but it's not that I'm looking for.
I'm doing a GPS-app with two tabbars. I track the distance in the map-view (using CLLocation) and when I change tab to a different view the stringtext that say what distance it is from when I started don't update immediately, it take a couple of seconds.
And when I press the stop button I want it to either wait those couple of seconds so the real distance updates. But I dont want to freeze the app. (*NSDate future = [NSDate dateWithTimeIntervalSinceNow: 3.0 ]; [NSThread sleepUntilDate:future];)
I'm saving the string with the distance in a cell in the second tab, so if I multitask while the app is going I want to just start the app and press stop. And then the new distance will be correct and saved. Hope I didn't confuse you with this much text I hope you understand what I asking for!
thx
Upvotes: 0
Views: 949
Reputation:
[label performSelector:@selector(setText:) withObject:newText afterDelay:3.0];
Upvotes: 2
Reputation: 41642
So what you want to do is use dispatch_after:
dispatch_after(3 seconds, dispatch_get_main_queue(), ^
{
myLabel.text = <the value you want to appear>;
} );
Upvotes: 0