-2
webView.evaluateJavaScript("getLangs()", completionHandler : { (value, error) in            
            print(value as Any)            
            })     

result

Optional(["English","Հայերեն","Русский"])
Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161

2 Answers2

1

Use guard statement to unwrap optionals:

guard let array = value as? [String] else { return }
print(array)

guard creates the variable that can be accessed from outside its block. It is useful to unwrap a lot of Optionals.

Check this for more details.

Agent Smith
  • 2,873
  • 17
  • 32
0
if let array = value as? [String]{ print(array) }// now you've got the array
Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161