无法声明另一个窗口 [英] Can't declare another window
问题描述
我正在尝试在MyThing.m中声明另一个窗口
I'm trying to declare another window in MyThing.m
@property (nonatomic, strong) UIWindow *window;
但是出现此错误
在类扩展中非法声明属性 "MyThing"(属性必须为"readwrite",而其主要 必须为只读")
Illegal redeclaration of property in class extension "MyThing" (attribute must be 'readwrite', while its primary must be 'readonly')
如果我将窗口重命名为其他名称,就可以了.这是为什么?窗口是否应在AppDelegate.h中声明一次?
If I rename window to something else, it is OK. Why is that? Is window meant to be declared once in the AppDelegate.h ?
推荐答案
我发现了问题,这与AppDelegate.h中声明的window属性无关.
I figure out the problem, it has nothing to do with the window property declared in AppDelegate.h
问题是MyThing符合UIApplicationDelegate,并且UIApplicationDelegate协议声明了一个属性
The problem is MyThing conforms to UIApplicationDelegate, and UIApplicationDelegate protocol declare a property
@property (nonatomic, retain) UIWindow *window NS_AVAILABLE_IOS(5_0);
所以我们必须做这两个
MyThing.h (就像AppDelegate.h一样)
MyThing.h (like AppDelegate.h does)
@interface MyThing : NSObject <UIApplicationDelegate>
@property (nonatomic, strong) UIWindow *window;
@end
OR
MyThing.m (合成协议中声明的window属性)
MyThing.m (synthesize the window property declared in protocol)
@implementation WYNAppDelegate
@synthesize window;
@end
这篇关于无法声明另一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!