swift - ElementQuiz 应用程序-线程 1 : breakpoint 1. 4

标签 swift xcode

我正在尝试使用“App Development with Swift”(来自 iBooks)一书构建 ElementQuiz 应用程序。当我运行该应用程序时,它崩溃并转到 AppDelegate 页面,并显示一条绿线,上面写着“线程 1:断点 1.4”。

这是 ViewController.swift:

// ViewController.swift

// ElementQuiz

import UIKit

class ViewController: UIViewController {
   override func viewDidLoad() {
      super.viewDidLoad()
      updateElement()
   }

   @IBOutlet weak var image view: UIImageView!

   @IBOutlet weak var answerLabel: UILabel!

   @IBAction func showAnswer(_sender: Any) {
      answerLabel.text = elementList[currentElementIndex]
   }

   @IBAction func gotoNextElement(_sender: Any) {
      currentElementIndex += 1
      if currentElementIndex >= elementList.count {
         currentElementIndex = 0
      }

      updateElement()
   }

   let elementList = ["Carbon", "Gold", "Chlorine", "Sodium"]

   var currentElementIndex = 0

   func updateElement() {
      answerLabel.text = "?" 

      let elementName = elementList[currentElementIndex]
      let image = UIImage(named: elementName)
      imageView.image = image
   }
} 

这是 AppDelegate.swift:

//AppDelegate.swift
//ElementQuiz

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

   // This is the line with the "signal SIGABRT" error.
   var window: UIWindow?

   func application(_application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

      //Override point for customization after application launch.
      return true
   }
}

那是我的代码。

最佳答案

删除此处的所有连接(见图)。只有您拥有此连接。

connection event

关于swift - ElementQuiz 应用程序-线程 1 : breakpoint 1. 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44459528/

相关文章:

ios - firebase runTransactionBlock

swift - Alamofire 返回错误

ios - 有什么方法可以使用正则表达式或通配符从 NSUserDefaults 获取对象

objective-c - Storyboard不会保存在 Xcode 中

ios - 使用 iCloud 文档存储的最佳方式

ios - 在 map 上重复图钉注释

swift - macOS 上的 EnvironmentObject 和 SceneDelegate

iphone - UITableviewcell 的 NSMutableArray 数据源

objective-c - 如何在 iOS 和 Mac 中使用搜索字段控件?

xcode - 模拟在较旧的 OS X 版本上运行