我正在尝试在 MyThing.m 中声明另一个窗口
@property (nonatomic, strong) UIWindow *window;
但是得到这个错误
Illegal redeclaration of property in class extension "MyThing" (attribute must be 'readwrite', while its primary must be 'readonly')
如果我将窗口重命名为其他名称,也可以。这是为什么?窗口是否意味着在 AppDelegate.h 中声明一次?
最佳答案
我弄明白问题了,跟AppDelegate.h中声明的window属性没有关系
问题是 MyThing 符合 UIApplicationDelegate,并且 UIApplicationDelegate 协议(protocol)声明了一个属性
@property (nonatomic, retain) UIWindow *window NS_AVAILABLE_IOS(5_0);
所以我们必须做其中任何一个
MyThing.h(就像 AppDelegate.h 一样)
@interface MyThing : NSObject <UIApplicationDelegate>
@property (nonatomic, strong) UIWindow *window;
@end
或
MyThing.m(综合协议(protocol)声明的窗口属性)
@implementation WYNAppDelegate
@synthesize window;
@end
关于ios - 无法声明另一个窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24715715/