should be a simple solution that I am missing. I have a Tab View Controller driven app that I would like to passcode protect whenever the app is launched or opened by the user. I have created a passcode class & view controller in IB.
I am trying to use the AppDelegate.m class applicationDidLoadInForeground method with the following code:
- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSUserDefaults *submissionDefaults = [NSUserDefaults standardUserDefaults];
if ([submissionDefaults boolForKey:@"passcodeActive"] == true)
{
PINAuthViewController *pinController = [[PINAuthViewController alloc] init];
[self presentViewController:pinController animated:YES completion:nil];
}
}
I have imported my PINAuthViewController class in the header
#import "PINAuthViewController.h"
but I am receiving an error when compiling “No visible @interface for ‘AppDelegate’ declares the selector ‘presentViewController:animated:completion’.
Can anyone advise what I am doing wrong? The intention is to dismiss the passcode View Controller if the passcode is entered correctly.
Many thanks, James
The app delegate can’t present a view controller since it’s not a subclass of UIViewController itself.
You need to change your code to: