Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 939 Bytes

README.md

File metadata and controls

19 lines (15 loc) · 939 Bytes

NotificationBug

A sample project demonstrating an iOS8 bug I discussed at this meetup in Tokyo.

It should log four scheduled notifications to the console, but under iOS8, it will usually log three.

Changing the position of the sleep() call as below causes it to behave normally, strongly suggesting that async behavior is to blame.

    while (YES) {
        [[UIApplication sharedApplication] cancelAllLocalNotifications];
        for (NSDate *date in [self dates]) {
            UILocalNotification *notification = [self defaultNotificationWithDate:date];
            [[UIApplication sharedApplication] scheduleLocalNotification:notification];
        }
        sleep(2);
        NSLog(@"Notifications: %@", [UIApplication sharedApplication].scheduledLocalNotifications);
    }