Unable to declare another window

I am trying to declare another window in MyThing.m

@property (nonatomic, strong) UIWindow *window; 

But get this error

Illegal redefinition of property into an extension of the "MyThing" class (the attribute must be "readwrite", and its primary must be "readonly")

If I rename the window to another, everything is fine. Why is this? Is a window declared once in AppDelegate.h?

0
source share
1 answer

I find out the problem, it has nothing to do with the declaration in AppDelegate.h

The problem is that MyThing matches UIApplicationDelegate, and the UIApplicationDelegate protocol declares a property

 @property (nonatomic, retain) UIWindow *window NS_AVAILABLE_IOS(5_0); 

So we have to do any of these

MyThing.h (e.g. AppDelegate.h)

 @interface MyThing : NSObject <UIApplicationDelegate> @property (nonatomic, strong) UIWindow *window; @end 

OR

MyThing.m (synthesizes a window property declared in the protocol)

 @implementation WYNAppDelegate @synthesize window; @end 
+2
source

Source: https://habr.com/ru/post/1232472/


All Articles