0

ViewController.m に配列が格納されています。しかし、アプリがバックグラウンドに入ると、配列から通知を投稿したいと考えています。

私のNSMutableArray「リスト」はViewController.mで作成されましたが、AppDelegate.mで使用する必要があります

- (void)applicationDidEnterBackground:(UIApplication *)application




for (NSString *thing in list) {
    UILocalNotification *notif = [[UILocalNotification alloc] init];
    notif.alertBody = thing.text;
    [[UIApplication sharedApplication] presentLocalNotificationNow:notif];
4

1 に答える 1

3

ViewController.m がメイン VC の場合:

ViewController *yourVC = (ViewController*)self.window.rootViewController;
yourVC.yourMutableArray = whateverYouWant;

ただし、データを NSUserDefaults 内に保存することをお勧めします。そうすれば、簡単にアクセスしてどこでも読み書きできます。ところで、appDelegate のそのメソッドからの localNotifications の提示は悪い考えです。アプリ ストアは、誰かがアプリを離れようとしたときの即時通知のファンではありません..できるとしても.

于 2013-07-09T23:39:38.793 に答える