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.

Click here for an example

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)

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top