Forum Archive

ObjectC "idleTimerDisabled" !?!

BillBaroude

Hi there,

I'm seaeching the right way to make work an ObjectC line of code to disable the Idle timer on iPhone (screen goes darker)
The original line of code (found on the web) is :
[UIApplication sharedApplication].idleTimerDisabled = YES;

My side, I can't figure out how to use this exaclty. After a bunch of tries, no way to make it works.
Here is the non working code I tried :

from objc_util import *

Switch off idle mode (ObjectC)

UIApplication = ObjCClass('UIApplication')
idleTimerDisabled = ObjCClass('idleTimerDisabled')
My_app = UIApplication.sharedApplication()
My_app.idleTimerDisabled = 'YES'

Any idea on the way to make it work ?

Thx !

JonB

The easiest way is to use the method exposed in the console module

import console
console.set_idle_timer_disabled(True)

Otherwise, you want to use True, not YES

JonB
UIApplication = ObjCClass('UIApplication')
My_app = UIApplication.sharedApplication()
My_app.idleTimerDisabled = True
BillBaroude

@JonB said:

mport console
console.set_idle_timer_disabled(True)

Thank a lot.
I wasn't far from finding using ObjectC, but the console method is way easier :)