ich eine Meldung zu machen und ein Tutorial auf sie zu beobachten und, wenn ich in getippt:Wie zeitIntervalSinceNow in Swift3 zu tun?
notification.fireDate = NSDate(timeIntervalSinceNow: 0)
es sagt
Argument Labels '(timeIntervalSinceNow :)' passen nicht alle verfügbaren Überlastungen
Wie behebe ich das? Hier ist mein Code:
import UIKit
import UserNotifications
class ViewController: UIViewController {
var timer = Timer()
var time = 10
override func viewDidLoad() {
super.viewDidLoad()
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: Selector(("Notification")), userInfo: nil, repeats: true)
// Do any additional setup after loading the view, typically from a nib.
}
func notification() {
time -= 1
if time <= 0 {
let notification = UILocalNotification()
notification.alertAction = "Call"
notification.alertBody = "You have a call right now"
notification.fireDate = NSDate(timeIntervalSinceNow: 0)
UIApplication.shared.scheduleLocalNotification(notification)
timer.invalidate()
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func pushNotification(_ sender: AnyObject) {
let AlertView = UIAlertController(title: "Time for your call!", message: "Press go to continue", preferredStyle: .alert)
AlertView.addAction(UIAlertAction(title: "Go", style: .default, handler: nil))
self.present(AlertView, animated: true, completion: nil)
}
}
Aber dann heißt es, ich muss es machen "notification.fireDate = NSDate() als Date" und dann funktioniert es nicht –
@LeoDabus Ich bekomme keinen Fehler, wenn ich das mache, was du gesagt hast, aber ich bekomme Thread 1: Signal SIGABRT –
@LeoDabus wo soll ich das hinstellen? –