容易循环引用。对target产生强引用。
NStimer解决循环引用问题
1.用block
2.利用消息转发
self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:[Proxy proxtWith:self] selector:@selector(timerTest) userInfo:nil repeats:YES];
+ (instancetype)proxtWith:(id)target
{
Proxy * x = [[Proxy alloc] init];
x.target = target;
return x;
}
- (id)forwardingTargetForSelector:(SEL)aSelector
{
return self.target;
}










网友评论