###前提・実現したいこと
swiftで目覚ましみたいなものを作りたいと思っています
プログラミング始めたばっかりの初心者なので、失礼なことをするかと思いますが何卒よろしくお願いします
###発生している問題・エラーメッセージ
alarm_teamA[66559:1819460] -[alarm_teamA.ViewController update]: unrecognized selector sent to instance 0x7fab83f03e60 alarm_teamA[66559:1819460] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[alarm_teamA.ViewController update]: unrecognized selector sent to instance 0x7fab83f03e60' それとxcodeの画面の方には class AppDelegate: UIResponder,UIApplicationDelegate { の右の方に Thread 1: signal SIGABRT と出ています
###該当のソースコード
swift
1import UIKit 2 3class ViewController: UIViewController { 4 5 override func viewDidLoad() { 6 super.viewDidLoad() 7 // Do any additional setup after loading the view, typically from a nib. 8 9 myLabel.text = getNowTime() 10 _ = Timer.scheduledTimer(timeInterval: 60, target: self, selector:#selector(UIMenuController.update), userInfo: nil, repeats: true) 11 } 12 13 override func didReceiveMemoryWarning() { 14 super.didReceiveMemoryWarning() 15 // Dispose of any resources that can be recreated. 16 } 17 18 @IBOutlet weak var myLabel: UILabel! 19 @IBOutlet weak var myDPvar: UIDatePicker! 20 21 private var tempTime: String = "00:00" 22 private var setTime: String = "00:00" 23 24 @IBAction func myDPFunc(_ sender: Any) { 25 print("test: myDP moved!") 26 let format = DateFormatter() 27 format.dateFormat = "HH:mm" 28 tempTime = format.string(from: myDPvar.date) 29 } 30 31 @IBAction func myButtonFunc(_ sender: Any) { 32 setTime = tempTime 33 print("test: myButton Pushed!") 34 } 35 36 func getNowTime()-> String { 37 let nowTime: Date = Date() 38 let format = DateFormatter() 39 format.dateFormat = "HH:mm" 40 let nowTimeStr = format.string(from: nowTime as Date) 41 return nowTimeStr 42 } 43 44 func update() { 45 let str = getNowTime() 46 myLabel.text = str 47 myAlarm(str: str) 48 } 49 50 func myAlarm(str: String) { 51 if str == setTime{ 52 alert() 53 } 54 } 55 56 func alert() { 57 let myAlert = UIAlertController(title: "alert", message: "ring ding", preferredStyle: .alert) 58 let myAction = UIAlertAction(title: "dong",style: .default) { 59 action in print("foo!!") 60 } 61 myAlert.addAction(myAction) 62 present(myAlert, animated: true,completion: nil) 63 64 } 65}
###試したこと
課題に対してアプローチしたことを記載してください
###補足情報(言語/FW/ツール等のバージョンなど)
xcode 9.1
swift3
alarm_teamAというのは何でしょうか?
Project名です。
回答1件
あなたの回答
tips
プレビュー