iPhone dev — performSelector:withObject:afterDelay or NSTimer?

后端 未结 3 1077
小蘑菇
小蘑菇 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:16

    Just to add a bit to the other answers, the case for a recursive call would be when the call might take an unknown amount of time - say you are calling a web service repeatedly with small amounts of data until you are finished. Each call may take some unknown amount of time so you have the code do nothing until the web call returns, then the next batch is sent out until no more data remains to be sent and the code does not call itself again.

提交回复
热议问题