I'm working in a small project and I faced this problem : text field is String by default so I need to take the input and convert it to integer then calculate I was searching for a way to solve the converting problem and I didn't find any working solution so can any one help me please ?
Asked
Active
Viewed 331 times
2 Answers
1
try like this
In Swift 2.0, toInt()
,replaced with initializers. (In this case, Int(someString).)
let myString : String = "50"
let x : Int? = Int(myString)
if (x != null) {
// converted String to Int
}

Sport
- 8,570
- 6
- 46
- 65
-
not worked in swift 2.x – Paraneetharan Saravanaperumal Jun 11 '15 at 06:23
-
1ParaSara now check @ParaSara – Sport Jun 11 '15 at 13:36
-
thanks for your update – Paraneetharan Saravanaperumal Jun 12 '15 at 03:14