what is the first step in (NSTimer release and invalidate)?

前端 未结 4 1218
深忆病人
深忆病人 2021-02-10 03:29

Can I send argument with @selector in NSTimer? If I want to release NSTimer, are the following steps right in dealloc?

<
4条回答
  •  感情败类
    2021-02-10 04:18

    The two methods do different things. If you own a timer (you retained it, or alloced it, or copied it) then you should release it. If you scheduled it on a run loop, then you must invalidate it for the run loop to release it. If you did both things, then you must release and invalidate the timer (however usually having the run loop owning the timer is sufficient).

提交回复
热议问题