gpt4 book ai didi

iphone - UIWIndow 未声明 iOS 4.3 AppDelegate

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:09:37 25 4
gpt4 key购买 nike

我刚刚下载了最新的 iOS SDK (4.3) 并注意到当我启动一个基于窗口的应用程序时,UIWindow 没有在头文件中声明,它只是作为一个属性被提及。

#import <UIKit/UIKit.h>

@interface GleekAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UILabel *label;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

我希望并记住旧的 SDK,上面的代码应该是

#import <UIKit/UIKit.h>

@interface GleekAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UILabel *label;

UIWindow *window;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

这只是 SDK 的新功能吗?

谢谢

最佳答案

新的 Objective-C 运行时能够合成 ivars 而无需显式声明它们。来自 Runtime Difference in The Objective-C Programming Language :

In general the behavior of properties is identical on both modern and legacy runtimes (see “Runtime Versions and Platforms” in Objective-C Runtime Programming Guide). There is one key difference: the modern runtime supports instance variable synthesis whereas the legacy runtime does not.

...

With the modern runtime, if you do not provide an instance variable, the compiler adds one for you.

来自 Runtime Versions and Platforms in Objective-C Runtime Programming Guide :

  • Phone applications and 64-bit programs on Mac OS X v10.5 and later use the modern version of the runtime.

  • Other programs (32-bit programs on Mac OS X desktop) use the legacy version of the runtime.

也看看这个问题:

关于iphone - UIWIndow 未声明 iOS 4.3 AppDelegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6310217/

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