prevent iphone to sleep swift

Swift
UIApplication.sharedApplication().idleTimerDisabled = true

Source

Also in Swift: