var importo = (importoPrevistoTF.text as NSString).floatValue
侃侃尔雅
浏览 1127回答 3
3回答
烙印99
SO Answer的潜在重复,使用NSNumberFormatterSwift示例:let number = NSNumberFormatter().numberFromString(numberString)if let number = number { let floatValue = Float(number)}示例(目标-C):NSNumber *number = [[NSNumberFormatter new] numberFromString: numberString];float floatValue = number.floatValue;