LegalFingers
LegalFingers

Reputation: 25

How to set a default 'top' value in UIPickerView?

this seems really simple but I can't find it online - basically I have a pickerView with some content sorted in alphabetical order. but I want the top-most value to say "Pick an Option: ". I can't just add it to my array because it's sorted so it will show up with "P"

how do I do this?

if it matters, the values for the picker come from keys in a dictionary

var pickerArray: [String] = myDictionary.keys.sorted()

so I basically would like to have a key that says "Pick an Option: " but that shows up at the TOP of the picker

Upvotes: 0

Views: 42

Answers (1)

matt
matt

Reputation: 535249

How about

var pickerArray: [String] = ["Pick an Option"] + myDictionary.keys.sorted()

Upvotes: 1

Related Questions