你可以这样做
var toPass1 : [String] = ["1.0","2.90","23"] var force = toPass1.map{ ($0 as NSString).floatValue }