Why I get error "Cannot synthesize weak property in file using manual reference counting" when defining delegate?
Solution 1
you don't have to have to use synthesize since Xcode 4.4 and LLVM 2.0 the compiler makes the synthesize automatically. you can remove the line
@synthesize delegate;
if you want to make the synthesize manually you can turn on "implicit synthesized properties" flag in your build settings by set it to YES
and you are using manual retain release you can't use weak/strong in your properties you should use retain/assign .
Solution 2
You need to set Weak References in Manual Retain Release
to YES
in your Apple LLVM 8.0 - Language - Objective C
under Build Settings
of your project, as shown below in screenshot-
Chen Li Yong
Currently, I'm a mainly mobile programmer (iOS, swift / obj-C) which currently lead and work in multiple projects.
Updated on June 27, 2022Comments
-
Chen Li Yong almost 2 years
I have protocol and class header in one file:
@protocol SomethingDelegate - (void) doSomething; @end @interface SomethingClass @property (nonatomic, weak) id <SomethingDelegate> delegate; @end
On the .m file:
@implementation SomethingClass // in here I got error "Cannot synthesize weak property in file using manual reference counting" @end
If I change it into like this:
@implementation SomethingClass @synthesize delegate; // in here I got error "Cannot synthesize weak property in file using manual reference counting" @end
Why is this happened? And how to fix this? The error disappear if I change from
weak
tostrong
. But that's not how delegate should be declared, right? How to properly declare a weak delegate?