The software is provided "as is", without warranty of any kind, express or implied, etc...

Timestamp

Calculate one hour diference - Objective-C

NSTimeInterval secondsInOneHour = 1*60 * 60; //(hour*min*sec) => seconds
NSDate *Now = [NSDate dateWithTimeIntervalSinceNow:0];
NSDate *previousHour = [NSDate dateWithTimeIntervalSinceNow:-secondsInOneHour];
double differnceInSeconds = [Now timeIntervalSinceDate:previousHour];
// already one hour after
if ( differnceInSeconds < 0 ){
   //TODO
}

User Persisted Request

Integer Input - Objective-C

int selectedSpeedOption = 0;
int MAXLEVELS_TOBE_DRAWN = 100;
BOOL validNumberFlag = YES;

while (validNumberFlag){
   NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:
         @"Number of levels to draw\n Valid inputs [1-%d]",MAXLEVELS_TOBE_DRAWN]
         defaultButton:@"OK" alternateButton:@"Cancel"
         otherButton:nil informativeTextWithFormat:@""];
  NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 50, 24)];
  [input setStringValue:@"2"];
  [alert setAccessoryView:input];
  NSInteger button = [alert runModal];
  if (button == NSAlertDefaultReturn) { // clicked OK button
      [input validateEditing];
      selectedSpeed = [input integerValue];
      if ( selectedSpeed <= MAXLEVELS_TOBE_DRAWN) { //valid input
      validNumberFlag = NO;
  }   else if (button == NSAlertAlternateReturn) { //clicked Cancel button
      selectedSpeedOption = -1;
      validNumberFlag = NO;
  }
}