Retaining repeating NSTimer for later access?

前端 未结 3 1488
隐瞒了意图╮
隐瞒了意图╮ 2021-01-28 04:53

I am creating an NSTimer in the createTimer method that I want to refer back to in the later cancelTimer method. To facilitate this I am taking ownersh

3条回答
  •  温柔的废话
    2021-01-28 05:12

    You need to invalidate before you release. After the timer has fire, you are the only one holding a retain on the timer. So when you call release, the timer deallocates. You then call invalidate on invalid memory and you crash.

提交回复
热议问题