0
我有一个switch语句,它利用nsuserdefaults bool函数来确定on和off。我的问题是如何在视图控制器中调用appdelegate.m方法,当switch key bool为yes时。基本上在视图controller.m中的第一个if语句中调用appdelagte.m方法。如何从appdelegate调用方法
Appdelegate.m
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
TUPushHelper * helper = [[TUPushHelper alloc] initWithTokenData:devToken];
[helper registerDevice];
}
Viewcontroller.m
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"SwitchKey"]) {
NSLog(@"ok");
}
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"SwitchKey"]) {
[[UIApplication sharedApplication]unregisterForRemoteNotifications];
}
发现了另一个问题:http://stackoverflow.com /问题/ 8233253 /调用一个函数合的appdelegate?RQ = 1 – peko 2013-03-25 16:55:22