0

In swift...., how can i ask to the user for data?

What i mean, is..., how can i do something similar to scanf() from C or readln() from pascal, but in swift? For example: Import UIkit Var a,b,c: Int //here i want to ask to the user for a and b values c = a + b Print(c)

8th Jan 2021, 5:00 AM
Nacho González
4 odpowiedzi
+ 5
Depends from where you want to take input. For console, you can use readLine() {as already told by others} But when creating an app, you would hardly be using console to get your input. There you can use UITextField for the same 👇 https://developer.apple.com/documentation/uikit/uitextfield and yes in both the cases, the input will be read in form of a string, you have to type case it to type Int in order to perform any operations like addition on them. here is an example 👇 https://code.sololearn.com/cYT15bj9Cc5u/?ref=app
8th Jan 2021, 6:10 AM
Arsenic
Arsenic - avatar
8th Jan 2021, 5:13 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 1
nice tysm, thats what i need. ty all
8th Jan 2021, 10:44 AM
Nacho González