Reputation: 561
I am looking to make an app that, after a given time of no use, will close or give a message to the user.
How can I implement this?
Upvotes: 0
Views: 252
Reputation: 7303
UKIDleTimer is what you're looking for. You create a timer that only fires when the system becomes idle and implement the following method in its delegate:
-(void) timerBeginsIdling: (id)sender {
// terminate app
[NSApp terminate];
}
Upvotes: 1
Reputation: 104032
How about:
[NSApp performSelector:@selector(terminate:)
withObject:nil
afterDelay:[your delay...]];
Upvotes: 0
Reputation: 14798
Look at various Hello World examples on the net for Objective C. Once you have a hello world example going, you'll want to add some event listeners to monitor user activity. When any of those event handlers are called as a result of a users' actions, they should set a variable with the time of that action. Finally, set up a timer to check for user inactivity, say once every 30 seconds, which checks that value, to see if it's exceeded the time at which you want the application to close. If so, then send an exit command.
Upvotes: 0