iphone SDK NSTimer - 为什么我需要多个?
这是一个尴尬的问题,但它涉及到 Xcode 和 iPhone SDK。
为什么我需要设置多个计时器? 2 个定时器是否比 1 个定时器占用更多的“抽动”,或者它们都基于相同的主内部时钟?
添加 1 个计时器例程并让它调用我需要发生的所有事情是否更好,或者有 5 或 6 个。我对编程并不陌生,但我对 xCode 完全陌生,只是想集中注意力它。
例如。如果我有一个计时器更新屏幕上的时钟,并且我还想更新 GPS 位置,有什么理由不让同一个计时器更新两者呢?
谢谢。
This is an embarrassing question but it involes Xcode and the iPhone SDK.
Why would I need to set more than one timer? And do 2 timers take up more 'tics' than 1 timer or are they all based on the same master internal clock?
Is it better to add 1 timer routine and just have it call all the things I need to make happen or have 5 or 6. I'm not new to programing but I'm completely new to xCode and just trying to wrap my head around it.
Eg. If I have a timer updating the clock on the screen, and I also want to update the GPS position, is there any reason not to have the same timer update both?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一是计时器委托将在单独的线程中运行。因此,在您的情况下,当只使用一个计时器时,如果 GPS 采集需要很长时间,您的屏幕会感觉没有响应,因为时钟会不定期更新。
One is that timer delegate will operate in separate threads. So in your case, when only one timer is used, if the GPS acquisition takes to much time, your screen will feel unresponsive because the clock will be unregularly updated.