tiamat
tiamat

Reputation: 961

add Strings to a var pickerDataSource : [String] = [String]()

I integrated a UIPickerView in my view and I want to add Strings dynamically.

here is my var declaration

var pickerDataSource : [String] = [String]()

how do I add String in a for statement ? such as

            for anItem in json as! [Dictionary<String, AnyObject>] {
            let nom = anItem["nom"] as! String
            let prenom = anItem["prenom"] as! String
            //add new String to pickerDataSource
}

Upvotes: 0

Views: 50

Answers (1)

Duncan C
Duncan C

Reputation: 131398

How about this?

pickerDataSource.append(prenom)

Upvotes: 1

Related Questions