gpt4 book ai didi

ios - 无法声明另一个窗口

转载 作者:行者123 更新时间:2023-11-28 22:02:46 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com