How do I prevent the iPhone screen from dimming or turning off while my application is running?
Objective-C
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
Swift
UIApplication.shared.isIdleTimerDisabled = true
In swift you can use this as
UIApplication.sharedApplication().idleTimerDisabled = true
Swift 3:
UIApplication.shared.isIdleTimerDisabled = true