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

内存管理,weak, unowned #70

Open
remlostime opened this issue Feb 25, 2017 · 1 comment
Open

内存管理,weak, unowned #70

remlostime opened this issue Feb 25, 2017 · 1 comment

Comments

@remlostime
Copy link

这一节我感觉还需加上使用unowned的例子才能更好地理解何时用unowned。其实,这里何时用weak,何时用unowned很模糊。怎么判断self不会被释放?

@porridgec
Copy link

我觉得挺清晰的:

  • 能保证closure在执行时self没被释放,放心用 unowned
  • 不能保证,则使用 weak

那么至于判断self是否会被释放,那就是开发者自己需要斟酌的事情了

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

2 participants