I defined a member instance frameCount which type is Int!, But when I reference it in block it's type become Int?. If I doesn't unwrap it Xcode will prompt complie error "Value of optional type 'Int?' not unwrapped; did you mean to use '!' or '?'?".
I can use it without unwrapping out of block.
//Without unwrapping
self.frameCount = self.frameCount + 1
optQueue.async { [weak self] in
//frameCount become Int?.
//If I doesn't unwrap it Xcode will prompt complie error "Value of optional type 'Int?' not unwrapped; did you mean to use '!' or '?'?"
self?.frameCount = (self?.frameCount)! + 1;
}
Int?, butself?.frameCountis.asyncis a GCD API[weak self]is pointless. GCD dispatch queues don't cause retain cycles. And don't misuse IUO.self?.frameCount += 1