Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__block 的解释以及在 ARC 和 MRC 下有什么不同? #43

Open
tbfungeek opened this issue Jan 7, 2020 · 0 comments
Open

__block 的解释以及在 ARC 和 MRC 下有什么不同? #43

tbfungeek opened this issue Jan 7, 2020 · 0 comments

Comments

@tbfungeek
Copy link
Owner

tbfungeek commented Jan 7, 2020

  • MRC 环境下,block 截获外部用 __block 修饰的变量,不会增加对象的引用计数
  • ARC 环境下,block 截获外部用 __block 修饰的变量,会增加对象的引用计数

所以,在 MRC 环境下,可以通过 __block 来打破循环引用,在 ARC 环境下,则需要用 __weak 来打破循环引用。

ARC和MRC下Block的使用注意

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant