我构建了一个带有四个组件的UIPickerView,我想将选中的每个组件和行分配给我的变量但是我得到了线程1:此函数中的断点1.1运行时错误
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int){
println("jjjj")
println(component)
switch(component){
case 0:
person = persons [component][row]
case 1:
year = persons [component][row]
case 2:
month = persons [component][row]
case 3:
day = persons [component][row]
default : break
}
}
我的完整代码是
import Foundation
import UIKit
class VariziJadidController: UIViewController,UIPickerViewDelegate,UIPickerViewDataSource {
@IBOutlet weak var mablagh: UITextField!
var person = ""
var year = ""
var month = ""
var day = ""
var persons = [
["احمد","حسین","حمید","مهدی","رضا"]
,["1394" , "1395" , "1396" , "1397" , "1398" , "1399" , "1400"]
,["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"]
,["31" , "30" , "29" , "28" , "27" , "26" , "25" , "24" , "23" , "22" , "21" , "20" , "19" , "18", "17" , "16" , "15" , "14" , "13" , "12" , "11" , "10" , "9" , "8" , "7" ,"6" , "5" , "4" , "3" , "2" , "1"]
]
override func viewDidLoad() {
super.viewDidLoad()
}
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int{
return persons.count
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int{
return persons [component].count
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String!{
return persons [component][row]
}
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int){
println("jjjj")
println(component)
switch(component){
case 0:
person = persons [component][row]
case 1:
year = persons [component][row]
case 2:
month = persons [component][row]
case 3:
day = persons [component][row]
default : break
}
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
var mojodiTemp : MojoodiSandoghController = segue.destinationViewController as MojoodiSandoghController
mojodiTemp.tempMojoodi = mablagh.text!
var HesabeHarFard : SoratHesabeAaza = segue.destinationViewController as SoratHesabeAaza
HesabeHarFard.person.text = person
HesabeHarFard.year.text = year
HesabeHarFard.month.text = month
HesabeHarFard.day.text = day
}
}
我该如何解决?