Swift 3.0版本适用
1.CGFloat 转化成String
dateCell.detailDateLabel.text = String.init(format:"%.2f", order.fare!)
2.String 转化成CGFloat
func StringToFloat(str:String)->(CGFloat){
let string = str
var cgFloat:CGFloat = 0
iflet doubleValue = Double(string)
{
cgFloat = CGFloat(doubleValue)
}
return cgFloat
}
func stringToInt(str:String)->(Int){
let string = str
var int:Int?
iflet doubleValue = Int(string) {
int = Int(doubleValue)
}
if int ==nil
{
return0
}
return int!
}