今天在使用协议的过程中,偶然发现这样使用
@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
时间: 2024-10-13 08:13:49