Swift 应用程序崩溃没有任何错误?

Swift app crashing without any errors?

我在 Swift 中有一个应用程序。我有一个视图控制器:

//
//  ViewController.swift
//  SwiftUIPickerFormatted
//
//  Created by Codepixl
//  Copyright (c) 2014
//

import UIKit

class FirstViewController: UIViewController,UIPickerViewDataSource,UIPickerViewDelegate,UIAlertViewDelegate {

    @IBOutlet weak var chapterPicker: UIPickerView!
    let chapterData = [1,2,3,4,5,6,7,8,9,10,11,12,13]
    let lessonData = [1,2,3,4,5,6,7,8,9,10]
    let classData = ["Pre Algebra","Algebra 1"]
    var data = ["ade","01","01"]
    override func viewDidLoad() {
        super.viewDidLoad()
        if(UIApplication.sharedApplication().canOpenURL(NSURL(string:"puffin://")!) == true){
            println("Can open Puffin links")
        }else{
            showPuffinAlert()
        }
        chapterPicker.delegate = self
        chapterPicker.dataSource = self

    }

    //MARK: - Delegates and datasources
    //MARK: Data Sources

    func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
        return 3
    }
    func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        if(component == 0){
            return classData.count
        }else if(component == 1){
            return chapterData.count
        }else if(component == 2){
            return lessonData.count
        }
        return 1
    }

    //MARK: Delegates
    func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
        if(component == 0){
            return classData[row]
        }else if(component == 1){
            return "Chapter " + String(chapterData[row])
        }else if(component == 2){
            return "Lesson " + String(lessonData[row])
        }
        return "Error!"
    }

    func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        if(component == 0){
            if(row == 0){
                data[0] = "ade"
            }else if(row == 1){
                data[0] = "ate"
            }
        }else if(component == 1 || component == 2){
            if(row+1 < 10){
                data[component] = "0"+String(row+1)
            }else{
                data[component] = String(row+1)
            }
        }
        println("puffin://www.phschool.com/webcodes10/index.cfm?wcprefix=\(data[0])&wcsuffix=\(data[1])\(data[2])&area=view")
    }
    func showPuffinAlert(){
        var createAccountErrorAlert: UIAlertView = UIAlertView()

        createAccountErrorAlert.delegate = self

        createAccountErrorAlert.title = "Oops!"
        createAccountErrorAlert.message = "It seems you do not have the Puffin web browser installed, which is required for this app to work. You can go ahead, but be aware the video and textbook links will not work."
        createAccountErrorAlert.addButtonWithTitle("I understand- Proceed.")
        createAccountErrorAlert.addButtonWithTitle("I'll download Puffin for free.")

        createAccountErrorAlert.show()
    }

    func alertView(View: UIAlertView!, clickedButtonAtIndex buttonIndex: Int){

        switch buttonIndex{

        case 0:
            NSLog("Proceed");
            break
        case 1:
            NSLog("DL");
            UIApplication.sharedApplication().openURL(NSURL(string: "https://itunes.apple.com/us/app/puffin-academy/id716707933?mt=8#")!)
            break
        default:
            NSLog("Default");
            break
            //Some code here..

        }
    }
    @IBAction func GoVideo(sender: AnyObject) {
        UIApplication.sharedApplication().openURL(NSURL(string:"puffin://www.phschool.com/webcodes10/index.cfm?wcprefix=\(data[0])&wcsuffix=\(data[1])\(data[2])&area=view")!)
    }
}

一切正常,直到我点击 "I understand-Proceed" 或 "I'll download Puffin for free" 或 GoVideo 按钮 - 它崩溃且没有错误。我完全不知道这里发生了什么......

编辑:我还清除了我的构建文件夹并手动删除了其中的所有内容,并在我的应用程序委托和视图控制器中添加了一个 println 以确保它们已更新,并且已经更新。模拟器也已经通关了

您的 Xcode 项目中可能有损坏的文件。只需创建一个新项目并尝试那里的代码。