您的位置:首页 > 其它

__weak弱引用的对象定义

2015-02-10 14:49 113 查看
苹果的文档中明确地写道:

You should decorate variables correctly. When using qualifiers in an object variable declaration,

the correct format is:“ClassName
* qualifier variableName;”.

按照这个说明,要定义一个weak型的NSString引用,它的正确写法应该是:

NSString * __weak str = @"hehe";

但很多人,包括我自已都用了错误的写法是:

__weak NSString *str = @"hehe";

那这里就有疑问了,既然文档说是错误的,为啥编译器不报错呢?文档又解释道:

Other variants are technically incorrect but are “forgiven” by the compiler. To understand the issue, see http://cdecl.org/ .
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐