iphone – iOS 5中的协议和分配属性
发布时间:2020-12-14 17:49:02 所属栏目:百科 来源:网络整理
导读:我正在尝试在iOS 5中创建自己的自定义代理. 在iOS 4中,我通常使用’Assign’属性: @property(nonatomic,assign) idAnyProtocol delegate; 现在,当我尝试合成时,我收到以下错误消息: error: Automatic Reference Counting Issue: Existing ivar 'delegate'
我正在尝试在iOS 5中创建自己的自定义代理.
在iOS 4中,我通常使用’Assign’属性: @property(nonatomic,assign) id<AnyProtocol> delegate; 现在,当我尝试合成时,我收到以下错误消息: error: Automatic Reference Counting Issue: Existing ivar 'delegate' for unsafe_unretained property 'delegate' must be __unsafe_unretained 有任何想法吗 ? 解决方法
此错误是因为在ARC ivars下默认为strong
此错误告诉您已使用__unsafe_unretained(assign)所有权声明了属性,但默认情况下,ivar具有__strong所有权,因此它们不能在一个中.您可以 >省略将自动创建的ivar __unsafe_unretained id <FileListDelegate> delegate; >定义属性以匹配ivar的隐式__strong所有权: @property (weak) id <FileListDelegate> delegate; 这三个选项无耻地从用户chrispix的答案中复制了this thread..Credit去了那里 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |