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

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -