I assume you're writing your code in UIViewController
. Just declare an @property NSInteger gender
in the .h file, and access the variable as self.gender
and set it with self.gender = 24
.
change a number to a variable?
-
27-06-2023 - |
Question
i need to change a number to a variable named "gender" so later in my "if statements" i can say something like "If Male button is pressed then Gender = 24". so i need to know how write a variable that looks something like Gender = 24 (it will change in the if statement). ive been reading around and i can't really figure out where i can assign variables.
that top line of code will look like float answer = (Gender + [shoeSize.text floatValue])/3;
when i figure out how to use the variables.
i hope you can help me! (also, sorry for my incompetence with xcode! im kinda new)
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow