gpt4 book ai didi

swift - 线程1 : Signal SIGABRT in Swift 3

转载 作者:行者123 更新时间:2023-11-30 12:47:50 27 4
gpt4 key购买 nike

此 iOS Swift 代码在运行时生成以下错误:

Thread1:Signal SIGBRT

谁能帮我确定可能的原因和解决方案吗?

(注意:Amazon.com 的 URL 被硬编码只是为了示例。)

import WatchKit
import Foundation

class InterfaceController: WKInterfaceController {
//Outlets erstellen
@IBOutlet var timer: WKInterfaceTimer!
@IBOutlet var slider: WKInterfaceSlider!
@IBOutlet var button: WKInterfaceButton!

//Outlet-Action, bei Änderung des Slider Werts
@IBAction func slider(_ value: Float) {
//Button kann genutzt werden
button.setEnabled(true)
//Text für den Button wird bestimmt
let roundedValue = Int(round(value))
UserDefaults.standard.setValue(roundedValue, forKey: "countdown")
let text: String = "FIRE (\(roundedValue)s)"
button.setTitle(text)
}

//Outlet-Action, wenn der Button gedrückt wird
@IBAction func fire(){
//Timer Farbe wird geändert, um diesen zu sehen
let swiftColor = UIColor(red: 1, green: 222, blue: 113, alpha: 1)
timer.setTextColor(swiftColor)
//Button wird deaktiviert + Button Text nun ...
button.setTitle("...")
button.setEnabled(false)
//Timer Wert abfragen
var countdown: Int = (UserDefaults.standard.value(forKey: "countdown")! as! Int)
//Timer starten
timer.setDate(NSDate(timeIntervalSinceNow: TimeInterval(countdown)) as Date)
timer.start()
//NSTimer mit 1 Sek Intervall
var clock = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: "countdown", userInfo: nil, repeats: true)

func countdown() {
countdown -= 1
if countdown == 4{
//HTTP-Request
var request = URLRequest(url: URL(string: "http://amazon.com")!)
request.httpMethod = "POST"
let session = URLSession.shared
session.dataTask(with: request) {data, response, err in
print("Entered the completionHandler")
}.resume()
//Timer auschalten
let schwarz = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
timer.setTextColor(schwarz)
//Button in Normalzustand
button.setTitle("FIRE (0s)")
button.setEnabled(true)
//Slider auf Standart
slider(0)
}
}


}

override func awake(withContext context: Any?) {
super.awake(withContext: context)

}

override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}

override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}

}

最佳答案

尝试清理您的项目。如果这不起作用,请重新创建您在制作项目时可能创建的所有 pod 文件。另外,检查同一对象是否有多个导出或操作。

关于swift - 线程1 : Signal SIGABRT in Swift 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41396058/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com