我在NSURLConnectionDelegate
中获得了预期可下载大小的指数值。
显示为1.34597e + 08。
现在我尝试使用以下代码将值转换为1.3459,但没有运气:
self.expectedDownloadSize = Float(response.expectedContentLength)
let s = self.expectedDownloadSize.description
let numberFormatter = NSNumberFormatter()
numberFormatter.numberStyle = NSNumberFormatterStyle.DecimalStyle
numberFormatter.maximumFractionDigits = 4
var num = numberFormatter.numberFromString(s as String)
self.expectedDownloadSize = num?.floatValue
如何获得预期的下载大小?