I have a PickerView which has different office choices and I want to reach this office references as Strings in another ViewController. My PickerViewController class :
import UIKit
class PickerViewController: UIViewController,UIPickerViewDataSource,UIPickerViewDelegate {
@IBOutlet weak var officePicker: UIPickerView!
let offices = ["Choice 1","Choice 2","Choice 3"]
override func viewDidLoad() {
super.viewDidLoad()
officePicker.dataSource=self
officePicker.delegate=self
}
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return offices.count
}
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
let value = offices[row]
}
}
I have a home screen which has office informations. I want to add office info which selected before with using PickerView to this screen from a database with comparing the office names.