Weak Reference to NSTimer Target To Prevent Retain Cycle
问题 I'm using an NSTimer like this: timer = [NSTimer scheduledTimerWithTimeInterval:30.0f target:self selector:@selector(tick) userInfo:nil repeats:YES]; Of course, NSTimer retains the target which creates a retain cycle. Furthermore, self isn't a UIViewController so I don't have anything like viewDidUnload where I can invalidate the timer to break the cycle. So I'm wondering if I could use a weak reference instead: __weak id weakSelf = self; timer = [NSTimer scheduledTimerWithTimeInterval:30.0f