UIPickerView,信号SIGABRT

时间:2017-04-22 16:41:36

标签: ios swift uipickerview

我遇到信号SIGABRT的问题,但我认为一切正常。

import UIKit

class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
    @IBOutlet weak var vysledek: UILabel!
    @IBOutlet weak var cisloJedna: UITextField!
    @IBOutlet weak var cisloDva: UITextField!
    @IBOutlet weak var znamenkoVyber: UIPickerView!
    var array = ["*", "/", "+", "-"]

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

    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 1
    }

    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return array.count;
    }

    func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        return array[row]
    }

    @IBAction func vypocitej(_ sender: Any) {
        if array == ["*"] {
            let vypocet = String(Int(cisloJedna.text!)! * Int(cisloDva.text!)!)
            vysledek.text = vypocet
        }
        else if array == ["/"] {
            let vypocet = String(Int(cisloJedna.text!)! / Int(cisloDva.text!)!)
            vysledek.text = vypocet
        }
        else if array == ["+"] {
            let vypocet = String(Int(cisloJedna.text!)! + Int(cisloDva.text!)!)
            vysledek.text = vypocet
        }
        else if array == ["-"] {
            let vypocet = String(Int(cisloJedna.text!)! - Int(cisloDva.text!)!)
            vysledek.text = vypocet
        }
    }
}

问题出在哪里?

0 个答案:

没有答案