0

我只想在几秒钟后进行一次简单的操作。我写了这个:

[NSTimer scheduledWimerWithTimeInterval:seconds 
                                 target:self
                               selector:@selector(someMethod:)
                               userInfo:nil
                                repeats:NO];

并且不关心返回值。

可以吗?被忽略的 NSTimer 对象会在someMethod:完成操作后被释放和释放吗?

4

1 回答 1

2

See References to Timers and Object Lifetimes in "Timer Programming Topics":

Because the run loop maintains the timer, from the perspective of object lifetimes there’s typically no need to keep a reference to a timer after you’ve scheduled it. ...

The first code example in "Scheduled Timers" is almost identical to yours, and also ignores the return value.

于 2013-06-20T08:28:19.070 回答