ARC error when declaring delegate ivar

僤鯓⒐⒋嵵緔 提交于 2019-11-30 10:52:44

Try something like the following (example from: http://vinceyuan.blogspot.com/2011/06/wwdc2011-session-323-introducing.html):

@interface SomeObject : NSObject {
   __weak id <SomeObjectDelegate> delegate;
}
@property (weak) id <SomeObjectDelegate> delegate;
@end

Please notice how the ivar is declared.

With ARC and iPhone Simulator 5.0 the following seems to work just fine (no warnings, etc...):

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

SomeObject.m

#import "SomeObject.h"

@implementation SomeObject
@synthesize delegate = _delegate;
@end

There is an issue where, even if you update XCode (4.2+) from the Mac App Store, as Apple requires, it leaves the old version of XCode on your computer. So, if you had XCode pinned to your launchpad, and launch it, you'll get all these errors as noted below. You have to find the newer version of XCode, say by using the Spotlight feature, run it, and then as one of its first tasks, it removes the old version of XCode. Then you have no more errors reporting like this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!