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

Receive udp packets in android gstreamer -

php - Extract Text from HTTP referer -

java - Callback from new thread to class from which thread was initiated -