首页 > 移动平台 > 详细

ios 协议(delegate)使用过程中遇到assign attribute must be unsafeunretained

时间:2015-03-30 16:31:45      阅读:244      评论:0      收藏:0      [点我收藏+]

今天在使用协议的过程中,偶然发现这样使用

@interface AppDelegate (){
    id<ChatDelegate>  testdelegate;
}
@property (nonatomic , assign) id<ChatDelegate> testdelegate;

@end

@implementation AppDelegate
@synthesize testdelegate;

会报错:

Existing instance variable ‘delegate‘ for property ‘delegate‘ with assign attribute must be unsafe unretained

修改成:


@interface AppDelegate (){
   __unsafe_unretained id<ChatDelegate>  testdelegate;
}
@property (nonatomic , assign) id<ChatDelegate> testdelegate;

@end

@implementation AppDelegate
@synthesize testdelegate;

就好了,这只是为了相容iOS4以下的版本

参考:http://www.cnblogs.com/lyanet/archive/2013/05/07/3064290.html


ios 协议(delegate)使用过程中遇到assign attribute must be unsafeunretained

原文:http://blog.csdn.net/lv_ruanruan/article/details/44751147

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!