How do I setup a second component with a UIPickerView
Thanks to @Bluehound for pointing me in the right direction. I had to look at some objective-c on GitHub to find out exactly how to do it, this is the answer I was looking for:
TimeViewController:
class TimeViewController: UIViewController, UIPickerViewDelegate {
@IBOutlet weak var timeSegueLabel: UILabel!
let minutes = Array(0...9)
let seconds = Array(0...59)
var recievedString: String = ""
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 2
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
//row = [repeatPickerView selectedRowInComponent:0];
var row = pickerView.selectedRowInComponent(0)
println("this is the pickerView\(row)")
if component == 0 {
return minutes.count
}
else {
return seconds.count
}
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
if component == 0 {
return String(minutes[row])
} else {
return String(seconds[row])
}
}
override func viewDidLoad() {
super.viewDidLoad()
timeSegueLabel.text = recievedString
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
This is the result: