Dan has inherited a pile of Objective-C. That’s not the WTF. The previous developer had some… creative problem solving techniques.

For example, he needed to show a splash screen, and after three seconds, make it vanish. You might be thinking to yourself, “So I set a timer for 3000 milliseconds, and then close the splash screen, right?”

- (void)viewDidLoad {
    [super viewDidLoad];
    count=0;
    timerSplashScreen = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(StartLoading) userInfo:nil repeats:YES];
}

-(void)StartLoading {
    if(count==3){
        [timerSplashScreen invalidate];
        // Close the splash screen
    }
    count++;
}

Of course not! You set a timer for 1 second, and then count how many times the timer has fired. When the count hits 3, you can close the splash screen. Oh, for bonus points, increment the count after checking the count, so that way you have a lovely off-by-one bug that means the splash screen stays up for 4 seconds, not 3.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!