ios - Swift - Array of Any to Array of Strings -


how can cast array declared container object array of strings (or other object)? example :

var array: [any] = [] . . . array = strings // strings array of strings 

i receive error : "cannot assign value of type strings type any"

how can do?

you can't change type of variable once has been declared, have create one, example safely mapping any items string flatmap:

var oldarray: [any] = [] var newarray: [string] = oldarray.flatmap { string($0) } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -