You can convert Float
to Int
in Swift like this:
var myIntValue:Int = Int(myFloatValue)
println "My value is \(myIntValue)"
You can also achieve this result with @paulm’s comment:
var myIntValue = Int(myFloatValue)
More Related Contents:
- How to cast self to UnsafeMutablePointer type in swift
- Swift double to string
- Strange Swift numbers type casting
- What’s the difference between “as?”, “as!”, and “as”?
- Check if `Any` value is object
- Failing cast in Swift from Any? to protocol
- Set operations in swift
- How to lock orientation of one view controller to portrait mode only in Swift
- How do you use String.substringWithRange? (or, how do Ranges work in Swift?)
- Examples of Delegates in Swift [closed]
- How to create USDZ file using Xcode converter?
- NSDate Comparison using Swift
- How to test equality of Swift enums with associated values
- dyld: Library not loaded: @rpath/libswift_stdlib_core.dylib
- Swift constants: Struct or Enum
- Sort Dictionary by values in Swift
- Swift async load image
- How to unwrap double optionals?
- Cannot assign property in method of struct
- How to detect a tap gesture location in SwiftUI?
- USB Connection Delegate on Swift
- How do I check if a string represents a number (float or int)?
- Value of type ‘StorageMetadata’ has no member ‘downloadURL’
- How to pass one SwiftUI View as a variable to another View struct
- iOS13 Navigation bar large titles not covering status bar
- How to access NSWindow from @main App using only SwiftUI?
- How do I find the beginning of the week from an NSDate?
- How to get user home directory path (Users/”user name”) without knowing the username in Swift3
- Swift compiler segmentation fault when building
- SwiftUI add inverted mask