ios 協議(delegate)使用過程中遇到assign attribute must be unsafeunretained
阿新 • • 發佈:2018-11-28
今天在使用協議的過程中,偶然發現這樣使用
@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
修改成:
@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