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
Post a Comment