替代NSTimer的方法有哪些?

5

我可以使用 [locationManager startUpdatingLocation] 在后台获取GPS位置,但我不知道如何安排计划。我已经尝试使用NSTimer进行调度,但很多人都说如果应用程序进入后台,NSTimer将会过期。

我想知道如何在没有使用NSTimers的情况下安排调用方法的计划。


1
请查看此链接 - http://stackoverflow.com/questions/3388781/scheduling-task-in-iphone - rishi
我不想使用本地/远程推送通知,我想要进行计划安排。其中一个用户提到要使用scheduledTimerWithTimeInterval,我在我的应用程序中使用了相同的方法,如下所示: theTimer=[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(Location) userInfo:nil repeats:YES]。 这个定时器会过期吗? - Perseus
@user562100- 如果你不想使用所有这些,那么你就必须使用线程。 - rishi
@RIP - 我想要使用推送通知或者计时器。我已经使用过 scheduledTimerWithTimeInterval(20分钟),它可以正常工作。但是很多人说它会过期,这是真的吗?如果不是,我想知道为什么它能够正常工作。我是否可以继续使用 scheduledTimerWithTimeInterval? - Perseus
1
我已经使用过它多次,但从未遇到任何问题。它总是对我很好用...我认为你可以放心使用它。 - rishi
3个回答

1

1

0

我认为你可以使用这个:

[self performSelector:@selector(_yourMethod) withObject:nil afterDelay:delay_in_milliseconds];

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接