不能声明另一个窗口 [英] Can't declare another window

查看:27
本文介绍了不能声明另一个窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 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);

所以我们必须做任何一个

So we must do either of these

MyThing.h(就像 AppDelegate.h 那样)

MyThing.h (like AppDelegate.h does)

@interface MyThing : NSObject <UIApplicationDelegate>

@property (nonatomic, strong) UIWindow *window;

@end

MyThing.m(合成协议中声明的window属性)

MyThing.m (synthesize the window property declared in protocol)

@implementation WYNAppDelegate

@synthesize window;

@end

这篇关于不能声明另一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆