am trying to get the string chosen by the user in the UIPickerView after he click the button, lets say the UIPicker name us myPicker
how can i return the picker text?
am trying to get the string chosen by the user in the UIPickerView after he click the button, lets say the UIPicker name us myPicker
how can i return the picker text?
You're thinking of this backwards. A picker doesn't store strings, it displays them. In order to use a picker, you have to implement the delegate method pickerView:titleForRow:forComponent:
, which almost always uses one or more arrays of strings to provide the text for each item in the picker.
You can ask the picker which row is selected for each component. You then look in your array and fetch the string stored at that index.
iOS and Mac OS follow the MVC design pattern. You need to learn it, understand it, and follow it yourself.
As a universal rule, you should not use view objects to store data. They display data to the user, and sometimes collect input from the user. The only information you should read from a view object is the information the user inputs. Anything else should be stored in your model. As soon as the user enters data, read that data and save it in your model. If you aren't following that rule, you are violating the MVC design pattern.