Created
March 3, 2020 18:41
-
-
Save foxicode/29a305238ef9e82f2930d2a9e8c4d0f3 to your computer and use it in GitHub Desktop.
Swift extension to convert String to Int
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension String { | |
func toInt() -> Int { | |
Int(self)! | |
} | |
func toIntOrNull() -> Int? { | |
Int(self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment