【发布时间】:2012-01-05 05:16:20
【问题描述】:
在我的 AppDelegate 中,我有
#import <UIKit/UIKit.h>
#import "CustomerProfile.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) int x;
@end
在B班,我愿意
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.x = 5;
然后在C班,我做
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.x = 4;
最终,在 D 类中,我打印出 x 和 x = 5 的结果。 x 应该是 4。 这让我很困惑。请就这个问题给我建议。 谢谢
【问题讨论】:
-
为澄清起见,您按以下顺序初始化类:B 类 - C 类 - D 类?
-
包含 D 类中的代码,并将日志语句放在 B 和 C 中的赋值以及 D 中的读取之前,以便您可以验证这些语句的运行顺序。
标签: iphone ios5 uiapplicationdelegate