Without knowing what you're wanting to do with health it is somewhat difficult to give you the best most succinct answer. Judging from what I can see of your code, it looks like you have a UILabel statusText that shows the changes each time a button is pressed to represent the latest amount of damage dealt. I'm assuming that since you don't have health set up with a @property & @synthesize that you intend to keep that information in the background, a.k.a. you won't be presenting it to the user.

Again, assuming, that you wish to keep track of health over the course of the game, you'll need to declare it outside of that method. Otherwise each time you run through that method it'll get reset back to 100. Thankfully, this is incredibly easy to do. Simply take

Code:

int health = 100;

and stick it right below

Code:

@synthesize statusText;

We've just changed health from being a local variable (only visible within that one method, to being an instance variable (visible within the entire class, so now other methods inside AttackViewController.m can use it).

Now each time we run through that method, health doesn't get reset back to 100. To get to your question,

how do I reset it to a different number

Click to expand...

simply take an int value of some kind (presumably one that you've calculated based off damage) and assign it to health.

Sorry that I didn't specify what I wanted, I want health to begin at 100 and decrease by a random number every time you click the button. However it keeps resetting health back to 100, am I returning it wrong? I keep getting the error "'return' with a value, in function returning void."

Sorry that I didn't specify what I wanted, I want health to begin at 100 and decrease by a random number every time you click the button. However it keeps resetting health back to 100, am I returning it wrong? I keep getting the error "'return' with a value, in function returning void."

Thank you so much you are amazing, but I have another problem. I got it to work and now I am trying to tell it to display "You Win" if health is less than or equal to 0 but I keep getting the error "syntax error before health" again here is my code. Thank You.

Haha sorry probably not going to do that, anyway another question. How do you take text from a Text Field and display it in a label. I know this is a really silly question to ask but I keep coming up with numbers.