(Nearly solved, but not quite) (My temporary solution is to use a void method and call it in every button, and in that way I can edit the code used by multiple buttons rather then when making improvements having to edit each individual buttons if statement)
I bet it's a really simple error i've made, but I can't find it.
I'm trying to show a previously-defined alert when an integer reaches 50; this is the if statement I use in the viewDidLoad method:
if(count == 50){
[alert show];
}
When the integer reaches 50, nothing happens. Where have I gone wrong?
The integer is changed like this in an IBAction:
count+=10;
If I remove the if statement and just leave the alert to show, it displays when the view loads. So the alert isn't the problem.
Someone pointed out that if this code is only run once in the viewDidLoad method and the integer is changed to 50 at a later stage it won't wait for the integer to be 50, instead will see the value not being 50 and not execute the alert ever.
So how would I watch the integer with code, and execute an alert when the integer is 50, But not call the alert in the action that is increasing the integer?
Oh and by the way I have tried calling the if statement in the action that increases the integer and that works but I have about 100 buttons that increase the integer count and checking if the value is 50 in each and every single button seems a bit space consuming and time consuming for all that copy and pasting. Also I plan on having more than just an alert happen when the integer reaches 50. Im sure there's a more efficient way of just checking if the value of the integer count is 50.