Swift中,如果要把字符串转换成数字类型(比如整型,浮点型等)。可以先转成NSString类型,让后再转。
//将文本框中的值转换成数字
var
i = (tf1.text
as
NSString
).intValue
f = (tf1.text
).floatValue
d = (tf1.text
).doubleValue