私は、通知を作り、その上にチュートリアルを見て、私はタイプされたときにされた:Swift3のtimeIntervalSinceNowの操作方法は?
notification.fireDate = NSDate(timeIntervalSinceNow: 0)
それは
引数ラベル「(timeIntervalSinceNowが:)」は任意の利用可能 オーバーロードと一致していないと言う
私はこれをどのように修正すればよいですか?ここに私のコードは次のとおりです。あなたが火の日は今になりたい場合は
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)
}
}
しかし、私はそれを 'Notification.fireDate = NSDate()としてDate'としなければならないと言います。それでうまくいきません。 –
@LeoDabusあなたが言ったことをするとエラーは発生しませんが、 1:signal SIGABRT –
@LeoDabusどこに置くべきですか? –