我在一个文件中有协议(protocol)和类头:
@protocol SomethingDelegate
- (void) doSomething;
@end
@interface SomethingClass
@property (nonatomic, weak) id <SomethingDelegate> delegate;
@end
在 .m 文件上:
@implementation SomethingClass // in here I got error "Cannot synthesize weak property in file using manual reference counting"
@end
如果我把它改成这样:
@implementation SomethingClass
@synthesize delegate; // in here I got error "Cannot synthesize weak property in file using manual reference counting"
@end
为什么会这样?以及如何解决这个问题?如果我从
weak
更改,错误就会消失至strong
.但这不应该是如何声明委托(delegate)的,对吧?如何正确声明弱委托(delegate)?
最佳答案
您需要设置Weak References in Manual Retain Release
至YES
在您的 Apple LLVM 8.0 - Language - Objective C
在 Build Settings
下您的项目,如下图所示 -
关于objective-c - 为什么在定义委托(delegate)时出现错误 "Cannot synthesize weak property in file using manual reference counting"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41035227/