ios - 在 Swift 中将 Int 转换为 Double

标签 ios swift

label.text = String(format:"%.1f hour", theOrder.bookingMins/60.0)

上面的代码只是得到错误:'Int' is not convertible to 'Double'

bookingMins 是 Int 类型,那么如何在 Swift 中将 Int 转换为 Double?似乎不像在 C 中那么简单。

最佳答案

试试 Double(theOrder.bookingMins)

关于ios - 在 Swift 中将 Int 转换为 Double,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27467888/

相关文章:

ios - xcode:在 Storyboard 中看不到导航项

ios - 分割 UITableView 单元格

swift - locationManager 是否为 :didUpdateLocations: method called at the same time in extension and its containing app

ios - 如何匹配两个语音文件并返回是否是同一个词?

objective-c - iOS ScrollView 禁用自动滚动到顶部

ios - IBOutlets 没有出现在 iPad Xcode 4 的 Storyboard 中

ios - 将 Uiimage 传递给 View Controller

ios - 双击主页按钮模糊应用程序屏幕截图

swift - macOS 菜单栏应用程序 : main menu not being displayed

ios - 按工作日名称swift3对字典数组进行排序