Dyl*_*ich 27 iphone ios automatic-ref-counting
我正在使用ARC(不,这不是NDA).我在我的界面中宣布我的ivar
id itemDelegate;
Run Code Online (Sandbox Code Playgroud)
然后我宣布财产:
@property (nonatomic, weak) id<mySecretDelegateYouAreNotSupposedToSeeOnSO> itemDelegate; (由于ARC而弱而不是分配)
在我的实现文件中,我只是合成它: @synthesize itemDelegate;
但是,我收到错误:
"Existing ivar 'ItemDelegate' for _weak property 'itemDelegate' must be _weak".
Run Code Online (Sandbox Code Playgroud)
谁知道什么是错的?谢谢你的帮助.
ARC - 自动参考计数
Wol*_*urs 46
尝试类似下面的内容(例如:http://vinceyuan.blogspot.com/2011/06/wwdc2011-session-323-introducing.html):
@interface SomeObject : NSObject {
__weak id <SomeObjectDelegate> delegate;
}
@property (weak) id <SomeObjectDelegate> delegate;
@end
Run Code Online (Sandbox Code Playgroud)
请注意ivar是如何申报的.
使用ARC和iPhone模拟器5.0,以下似乎工作正常(没有警告等...):
SomeObject.h
@class SomeObject;
@protocol SomeObjectDelegate <NSObject>
- (void)someObjectDidFinishDoingSomethingUseful:(SomeObject *)object;
@end
@interface SomeObject : NSObject {
__unsafe_unretained id <SomeObjectDelegate> _delegate;
}
@property (nonatomic, assign) id <SomeObjectDelegate> delegate;
@end
Run Code Online (Sandbox Code Playgroud)
SomeObject.m
#import "SomeObject.h"
@implementation SomeObject
@synthesize delegate = _delegate;
@end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17779 次 |
| 最近记录: |