Question: I have array `[["PT"], ["GE", "DE", "PL", "BY"], ["CZ", "US"]]` and I'd like to use it in `UISegmentedControl` that I created programmatically:

```
 for i in 0..<array.count {
            mySegmentControl.insertSegment(withTitle: array[i], at: i, animated: false)
        }

```

I see error: 

> 
> Cannot convert value of type '[String]' to expected argument type 'String?'
> 
> 
> 

It's true, But I need that `PT` would be at first segment title, `GE..BY` at second and etc.

Answer: 
What's the type of array? Is it [[String]], then you can do this (Playground code):

```
extension UISegmentedControl {

    func updateTitle(array titles: [[String]]) {

        removeAllSegments()
        for t in titles {
            let title = t.joined(separator: ", ")
            insertSegment(withTitle: title, at: numberOfSegments, animated: true)
        }

    }
}

let control = UISegmentedControl()
control.updateTitle(array: [["PT"], ["GE", "DE", "PL", "BY"], ["CZ", "US"]])
control.titleForSegment(at: 1)

```
If you want `PT` would be at first segment, `GE..BY` at second and etc.. So try like this.

```
for (index,subArray) in array.enumerated() {
     if subArray.count > 1 {
          let title = subArray.first! + ".." + subArray.last!
          mySegmentControl.insertSegment(withTitle: title, at: index, animated: false)
     }
     else if subArray.count > 0 {
          let title = subArray.first!
          mySegmentControl.insertSegment(withTitle: title, at: index, animated: false)
     }
}

```