Fun Fact: Man beachte die Kommentare in Zeile 13–14
Alles anzeigen
Es liegt definitiv an Swift…
Die Variante hier rennt natürlich auch erfolgreich:
Alles anzeigen
Was lernen wir daraus? Schließe nie von Funktionalität in Objective–C auf Funktionalität in Swift…
Quellcode
- func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
- application.cancelAllLocalNotifications()
- let calendar = NSCalendar.currentCalendar()
- let startDate = NSDate()
- var notificationDate = calendar.dateByAddingUnit(NSCalendarUnit.Minute, value: 5, toDate: startDate, options: [])
- let localNotifaction = UILocalNotification()
- localNotifaction.alertTitle = "hi"
- localNotifaction.alertBody = "what a body!"
- localNotifaction.fireDate = notificationDate
- application.scheduleLocalNotification(localNotifaction)
- // Uncomment lower line to get both the local notifications at the latest print!
- //print(application.scheduledLocalNotifications)
- notificationDate = calendar.dateByAddingUnit(NSCalendarUnit.Minute, value: 10, toDate: startDate, options: [])
- localNotifaction.alertTitle = "hi again"
- localNotifaction.alertBody = "cool body"
- localNotifaction.fireDate = notificationDate
- application.scheduleLocalNotification(localNotifaction)
- print(application.scheduledLocalNotifications)
- print(application.scheduledLocalNotifications?.count)
- // Override point for customization after application launch.
- return true
- }
Es liegt definitiv an Swift…
Die Variante hier rennt natürlich auch erfolgreich:
Quellcode
- func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
- application.cancelAllLocalNotifications()
- let calendar = NSCalendar.currentCalendar()
- let startDate = NSDate()
- var notificationDate = calendar.dateByAddingUnit(NSCalendarUnit.Minute, value: 5, toDate: startDate, options: [])
- var localNotifaction = UILocalNotification()
- localNotifaction.alertTitle = "hi"
- localNotifaction.alertBody = "what a body!"
- localNotifaction.fireDate = notificationDate
- application.scheduleLocalNotification(localNotifaction)
- // Uncomment lower line to get both the local notifications!
- //print(application.scheduledLocalNotifications)
- notificationDate = calendar.dateByAddingUnit(NSCalendarUnit.Minute, value: 10, toDate: startDate, options: [])
- localNotifaction = UILocalNotification()
- localNotifaction.alertTitle = "hi again"
- localNotifaction.alertBody = "cool body"
- localNotifaction.fireDate = notificationDate
- application.scheduleLocalNotification(localNotifaction)
- print(application.scheduledLocalNotifications)
- print(application.scheduledLocalNotifications?.count)
- // Override point for customization after application launch.
- return true
- }
Was lernen wir daraus? Schließe nie von Funktionalität in Objective–C auf Funktionalität in Swift…
«Applejack» "Don't you use your fancy mathematics to muddle the issue!"
Iä-86! Iä-64! Awavauatsh fthagn!
Iä-86! Iä-64! Awavauatsh fthagn!
kmr schrieb:
Ach, Du bist auch so ein leichtgläubiger Zeitgenosse, der alles glaubt, was irgendwelche Typen vor sich hin brabbeln. :-P