所以我在 ViewController.m 中有一个方法,只需按一下按钮即可发布通知(到通知中心)
继承 ViewController.m 的方法
- (IBAction)buttonPush:(id)sender {
//clear NC
[[UIApplication sharedApplication] cancelAllLocalNotifications];
//make mutablearray
NSMutableArray *list = [NSMutableArray array];
[list addObject:first];
[list addObject:second];
[list addObject:third];
//post notification
for (UITextField *thing in list) {
UILocalNotification *notif = [[UILocalNotification alloc] init];
notif.alertBody = thing.text;
[[UIApplication sharedApplication] presentLocalNotificationNow:notif];
NSLog(@"looped!");
}
}
我想要做的是在以下方法中使用上述方法(在 AppDelegate.m 中):
- (void)applicationDidEnterBackground:(UIApplication *)application