将文本字段中的值分配给 int 变量以与其他变量进行一些数学运算,然后 return 吗?

Assign the value from a text field into an int variable to do some math with other variables and then return it?

此处显示的代码将变量的值分配给文本字段,我想做相反的事情。 _Initial.text = [NSString stringWithFormat:@"%f", init];

与上面的代码相反。请帮忙

与之相反的是将字符串转换为浮点数。你可以这样做

init = [_Initial.text floatValue];

提问前应搜索答案。

NSString *intString = @"123";
NSString *floatString = @"456.789";
int intVal = [intString intValue];
float floatVal = [floatString floatValue];
printf("%i %f\n",intVal,floatVal);