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 -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -