Reputation: 79
Please can you help me, I am new to programing and need a little bit of help. I am trying to cause a button called “rearmbutton” to stay hidden when the following condition is met:
_currentData.heartrate > 0
I have tried to implement this into my code where there are different conditions already in place that keep this button hidden without any success. I have searched about without much luck at finding a solution which is why I am now here asking for help.
I have checked the code that keeps the button hidden before changing it and confirmed that the button does stay hidden when the conditions are met.
With my addition to the code, my application malfunctions and the button does not stay hidden, instead it becomes stuck in its visible state.
Here is what I have completed so far, you can see in the 6th line from the bottom I have already tried to use the code, but it is not working, please can you explain where i am going wrong and how i might fix this please:
//////////////////////////////
// COOLDOWN - we are cooling down from an event -> no alarm
if (_coolDownPeriod > 0 && [NSDate timeIntervalSinceReferenceDate] < _coolDownPeriod) {
DLog(@"Cooling down");
_shouldAlarm = NO;
int time = (int) (_coolDownPeriod - [NSDate timeIntervalSinceReferenceDate]);
int min = floor((float) time / 60.0);
int sec = time - (60*min);
_timeLeftInCoolDownLabel.text = [NSString stringWithFormat:@"Time left until rearmed: %.2d:%.2d", min, sec];
_rearmButton.hidden = NO;
} else {
if (_currentData.heartrate > 0) _timeLeftInCoolDownLabel.text = @"";
_rearmButton.hidden = YES;
DLog(@"Rearm Hidden")
}
Thanks,
Chris
Upvotes: 0
Views: 142
Reputation: 42987
Wrapping the if
condition within {}
will fix i guess
if (_currentData.heartrate > 0)
{
_timeLeftInCoolDownLabel.text = @"";
_rearmButton.hidden = YES;
DLog(@"Rearm Hidden")
}
Upvotes: 2