iOS: __weak vs (weak)

和自甴很熟 提交于 2019-12-04 11:23:55

Yes. The first example declares a weak instance variable called usernameField, but the second declares a weak property called usernameField, and an instance variable called _usernameField that is accessed by the property.

If you declare it in an @interface section of the .m file, then it can only be accessed in that .m file (unless you mess with the Objective-C runtime).

The difference is not in the weak reference but just in the fact that the first is an instance and the second is a @property.

__weak and (weak) is the same thing, but the second is used as attribute for properties.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!