天天看點

iOS--錯誤集錦--Capturing 'self' strongly in this block is likely to lead to a retain cycle

申明:此為本人學習筆記,若有纰漏錯誤之處的可留言共同探讨

問題

iOS--錯誤集錦--Capturing 'self' strongly in this block is likely to lead to a retain cycle

這個問題實際上就是代碼塊循環引用問題。

解決的方法有兩種,一種是這樣子的寫法:把MYQRCodeView寫為__weak【注 myQRCodeView 它是一個繼承View的自定義View】

iOS--錯誤集錦--Capturing 'self' strongly in this block is likely to lead to a retain cycle

另一種辦法是這樣寫寫的:先把剛剛的myQRCodeView寫成屬性

iOS--錯誤集錦--Capturing 'self' strongly in this block is likely to lead to a retain cycle

然後這樣把VC寫為__weak 

iOS--錯誤集錦--Capturing 'self' strongly in this block is likely to lead to a retain cycle

循環引用的問題就解決了~

繼續閱讀