comparison between point and integer

Posted by LawVS on Stack Overflow See other posts from Stack Overflow or by LawVS
Published on 2010-02-22T14:35:16Z Indexed on 2010/05/09 5:18 UTC
Read the original article Hit count: 164

Filed under:
|
|
|

Right, basically I want to add two numbers together. It's for a working hours calculator and I've included parameters for a night shift scenario as an if statement. However, it now mucks up the day shift pattern. So I want to sort out that if the start time is below 12, then it'll revert to the original equation shown in the code instead of the if statement.

-(IBAction)done:(id)sender {
    int result = [finishHours.text intValue] - [startHours.text intValue];
    totalHours.text = [NSString stringWithFormat:@"%d", result];
    if (result < 0) {
            totalHours.text = [NSString stringWithFormat:@"%d", result * -1];

    }
    if (result < 12) {
            totalHours.text = [NSString stringWithFormat:@"%d", result + 24];
    }
    if (startHours < 12) {
            totalHours.text = [NSString stringWithFormat:@"%d", result - 24];
    }

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about if-statement