-2

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 ?

0

2 Answers 2

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
    }
Sign up to request clarification or add additional context in comments.

2 Comments

not worked in swift 2.x
ParaSara now check @ParaSara
0

myString.toInt() - convert the string value into int .

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.