gpt4 book ai didi

iphone - 我不断收到 Thread 1 : signal SIGABRT in Xcode

转载 作者:搜寻专家 更新时间:2023-11-01 06:44:48 25 4
gpt4 key购买 nike

我正在尝试为 iPhone 编写一个简单的快速猜测应用程序。代码运行成功,显示“Build Succeeded”。但是,我不断收到特定行的这条消息:“线程 1:SIGABRT 信号”。

该行包含“num += Int( (rand()%4) + 1)”,这在 Playground 上运行良好。

谁能告诉我如何解决这个问题?

import UIKit

class ViewController: UIViewController {


var num = 0


@IBOutlet var GuessField: UITextField!


@IBOutlet var ResultLabel: UILabel!


@IBOutlet var ScoreLabel: UILabel!


@IBAction func NewGameButton(sender: UIBarButtonItem) {


num += Int( (rand()%4) + 1)

/* Random numbers generated at num range from 1 to 4, which respectively
correspond to strings BMW, Mercedes, Lamborgini, and Ford. */

}




override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

@IBAction func ResultButton(sender: AnyObject) {

if GuessField.text == "BMW" {
if num == 1 {ResultLabel.text = "You Win!"}
else {ResultLabel.text = "Try Again!"}

}

if GuessField.text == "Mercedes" {
if num == 2 {ResultLabel.text = "You Win!"}
else {ResultLabel.text = "Try Again!"}

}


if GuessField.text == "Lamborgini" {
if num == 3 {ResultLabel.text = "You Win!"}
else {ResultLabel.text = "Try Again!"}

}

if GuessField.text == "Ford" {
if num == 4 {ResultLabel.text = "You Win!"}
else {ResultLabel.text = "Try Again!"}

}


}

}

最佳答案

如果您创建了一个控件并向 View Controller 添加了一个 socket 连接,然后在从控件的连接中正确移除 socket 连接之前从页面中删除了控件,则会发生“线程 1:信号 SIGABRT”错误。我以前有同样的问题。也可能是说您的类(class)不符合 KeyValueCoding 标准或其他内容。确保在删除控件之前清除控件的所有连接。

关于iphone - 我不断收到 Thread 1 : signal SIGABRT in Xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31595114/

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