Im wanting to show an alert when the user has been using the app for an hour
In the app delegate:
First I tried this: Displaying UIAlertView after some time
Then I tried
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self performSelector:@selector(showAlert) withObject:nil afterDelay:3600];
return YES;
}
-(void)showAlert{
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"title!"
message:@"message!"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil];
[alert show];
}
In both examples I tried using various figures in the after delay. No matter what I put for the delay, the timer fires after a min every time?
UPDATE:
This is correct code, I had also left this in the viewDidLoad in my view controller in addition to delegate so it was also firing that method. Thanks all
If this is what you do:
you should edit your question to this, and add additional information, as the problem has to be somewhere else.
Otherwise, this is your answer.