We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
原文: 在b非nil时,a和b指向同一个内存地址,在b变nil时,a变nil。此时向a发送消息不会崩溃:在Objective-C中向nil发送消息是安全的。 理解: __weak someType *a = someInstance; __weak someType *b = someInstance; b = nil; 此时a是不会变nil的, 即使执行someInstance = nil; 假如在这之前还有 someType *strongInstance = someInstance; a也不会变nil,只有当someInstance的引用计数变为0时,那些weak指向它的才会变nil
The text was updated successfully, but these errors were encountered:
的确,a和b指向同一个内存地址,在b变nil时,a变nil,本身就不严谨;a和b指向同一个内存地址,不代表改变b就一定会改变内存地址的值,b = nil,难道a就变了么。
Sorry, something went wrong.
不是这个意思吧,意思是对象本身被释放了,弱引用就指向nil 了,而不像 assign 会产生野指针
解答一些issue问题 #98 #6 #138
372393b
No branches or pull requests
原文:
在b非nil时,a和b指向同一个内存地址,在b变nil时,a变nil。此时向a发送消息不会崩溃:在Objective-C中向nil发送消息是安全的。
理解:
__weak someType *a = someInstance;
__weak someType *b = someInstance;
b = nil;
此时a是不会变nil的,
即使执行someInstance = nil;
假如在这之前还有 someType *strongInstance = someInstance;
a也不会变nil,只有当someInstance的引用计数变为0时,那些weak指向它的才会变nil
The text was updated successfully, but these errors were encountered: