【发布时间】:2017-02-02 11:03:07
【问题描述】:
在我的 AppDelegate 中,我有一个属性。它很强大并且属于自定义类(它是 NSObject 的子类)。当应用程序进入后台时,它变为 NULL。这种行为是不确定的,不能轻易复制(即使使用模拟内存警告选项)。它是随机发生的。
我的理解是,当应用程序进入后台并且如果其他应用程序需要内存时,该应用程序将被终止。但在这种情况下,应用程序并未终止,但特定属性变为空。
我没有在我的任何 ViewController 中实现 didReceiveMemoryWarning。
请帮帮我。
编辑:
这是我的 AppDelegate 外观示例
AppDelegate.h
@interface AppDelegate : UIResponder
@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) UINavigationController *navigationController;
@property (nonatomic, strong) Person *person;//This is the custom class
@end
AppDelegate.m
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:[UIViewController new]];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
@end
【问题讨论】:
-
向我们展示您的 AppDelegate 代码。
-
@davidf2281 我已经编辑了我的问题。请检查。
标签: ios objective-c