override func viewDidLoad(){super.viewDidLoad()
//get the values from sql/Json
let url = URL(string: "https://example.com/dropdownmenu/phpGet.php")
let data = Data(contentsOf: url! as URL)
var tmpValues = try! JSONSerialization.jsonObject(with: data as Data, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSArray
tmpValues = tmpValues.reversed() as NSArray
reloadInputViews()
for candidate in tmpValues {
if let cdict = candidate as? NSDictionary {
//fullName is the column name in sql/json
let names = cdict["fullName"]
self.values.append(names! as AnyObject)
}
}
}
Run Code Online (Sandbox Code Playgroud)