Swift 2.x에서 string(문자)를 int(숫자)로 바꿔 주는 .toInt() 함수가 없어졌네요. 헐! 그 대신 문자열을 제어할 수 있는 초기자(initializer), 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
// from string to int in swift | |
let intString: String = "256" | |
let stringInt: Int? = Int(intString) |
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.