iPhone dev — performSelector:withObject:afterDelay or NSTimer?

后端 未结 3 1084
小蘑菇
小蘑菇 2021-02-14 10:06

To repeat a method call (or message send, I guess the appropriate term is) every x seconds, is it better to use an NSTimer (NSTimer\'s scheduledTimerWithTimeInterval:ta

3条回答
  •  别那么骄傲
    2021-02-14 10:20

    A timer is more suited to a strictly defined interval. You will lose accuracy if you have your function call itself with a delay because its not really synced to a time interval. There's always the time taken to run the actual method itself as well which puts the interval out.

    Stick with an NSTimer, I'd say.

提交回复
热议问题