How can I avoid this warning in xcode. Here is the code snippet:
[player(AVPlayer object) addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(0.1, 100)
queue:nil usingBlock:^(CMTime time) {
current+=1;
if(current==60)
{
min+=(current/60);
current = 0;
}
[timerDisp(UILabel) setText:[NSString stringWithFormat:@"%02d:%02d",min,current]];///warning occurs in this line
}];
Best Answer
The capture of
self
here is coming in with your implicit property access ofself.timerDisp
- you can't refer toself
or properties onself
from within a block that will be strongly retained byself
.You can get around this by creating a weak reference to
self
before accessingtimerDisp
inside your block: