Reputation: 125
I want to return to my storyboard's initial viewcontroller after X time of user inactivity (no touch events fired). After some research I see that the most common way of detecting inactivity is to fire an NSTimer and reset the interval when an event is fired. To detect a fired event, we override [UIApplication sentEvent:] in a subclass of UIApplication. This is the part where I'm kind of stuck.
I'm looking at this project as reference
http://www.icodeblog.com/2011/09/19/timing-out-an-application-due-to-inactivity/
https://github.com/elc/ELCUIApplication
I'm not sure how to implement a similar functionality when working with storyboards. I tried something similar to that github projet; I created a new class that was a subclass of UIApplication, overrode the needed method and finally changed the targeted class in the main function (from my appdelegate to the new class that subclassed UIApplication). By doing so I got the following error
The app delegate must implement the window property if it wants to use a main storyboard file.
The appDelegate in the github is a subclass of NSObject and manually loads up the initial view in his window property from what I understand, while my appDelegate is a subclass of UIResponder which itself is a superclass of UIApplication. I'm not sure how to proceed, I already have the window property in my AppDelegate and synthesized, but I'm not sure what to do with it.
Any help would be greatly appreciated!
Upvotes: 3
Views: 1687
Reputation: 385650
It sounds like you changed the wrong argument to UIApplicationMain
.
The default call to UIApplicationMain
looks like this:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
The third argument (nil
by default) is the name of the UIApplication
class to use. If it's nil, the app just uses UIApplication
.
The fourth argument is the name of the UIApplicationDelegate
class to use.
It sounds like you changed the fourth argument, but you should have changed the third argument:
return UIApplicationMain(argc, argv,
NSStringFromClass([MyApplication class]),
NSStringFromClass([AppDelegate class]));
Upvotes: 12