I'm just trying to build a Facebook Login page for my iOS app, but it keeps breaking when IBOutlet in my LoginViewController tries to connect to a UIActivityIndicatorView. Here is the error that I get:
2013-12-10 00:29:11.062 uConnect[2254:70b] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key loader.'
Here is my interface
@interface UConnectLoginViewController : UIViewController
-(void)loginFailed;
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView* loader;
@end
here is my implementation
@interface UConnectLoginViewController ()
-(IBAction)performLogin:(id)sender;
@end
@implementation UConnectLoginViewController
@synthesize loader;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(IBAction)performLogin:(id)sender
{
[self.loader startAnimating];
UConnectAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openSession];
}
-(void)loginFailed
{
[self.loader stopAnimating];
}
@end
In the xib file I already hooked up the Outlet to the view.
EDIT:
Here is the full console error log:
2013-12-10 18:02:13.830 uConnect[3596:70b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UConnectLoginViewController 0x8a8c4a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key spinner.'
*** First throw call stack:
(
0 CoreFoundation 0x017b85e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0153b8b6 objc_exception_throw + 44
2 CoreFoundation 0x018486a1 -[NSException raise] + 17
3 Foundation 0x011fc9ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x01168cfb _NSSetUsingKeyValueSetter + 88
5 Foundation 0x01168253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 Foundation 0x011ca70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
7 UIKit 0x0054ba15 -[UIRuntimeOutletConnection connect] + 106
8 libobjc.A.dylib 0x0154d7d2 -[NSObject performSelector:] + 62
9 CoreFoundation 0x017b3b6a -[NSArray makeObjectsPerformSelector:] + 314
10 UIKit 0x0054a56e -[UINib instantiateWithOwner:options:] + 1417
11 UIKit 0x003bc605 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
12 UIKit 0x003bcdad -[UIViewController loadView] + 302
13 UIKit 0x003bd0ae -[UIViewController loadViewIfRequired] + 78
14 UIKit 0x003bd5b4 -[UIViewController view] + 35
15 UIKit 0x003ccab9 -[UIViewController shouldAutorotate] + 36
16 UIKit 0x003cce01 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 297
17 UIKit 0x006515e5 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2330
18 UIKit 0x003c90fc -[UIViewController presentViewController:withTransition:completion:] + 6433
19 UIKit 0x003c961f -[UIViewController presentViewController:animated:completion:] + 130
20 uConnect 0x00002c7a -[UConnectAppDelegate showLoginView] + 218
21 uConnect 0x000029b7 -[UConnectAppDelegate application:didFinishLaunchingWithOptions:] + 647
22 UIKit 0x002a3355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
23 UIKit 0x002a3b95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
24 UIKit 0x002a83a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
25 UIKit 0x002bc87c -[UIApplication handleEvent:withNewEvent:] + 3447
26 UIKit 0x002bcde9 -[UIApplication sendEvent:] + 85
27 UIKit 0x002aa025 _UIApplicationHandleEvent + 736
28 GraphicsServices 0x0375f2f6 _PurpleEventCallback + 776
29 GraphicsServices 0x0375ee01 PurpleEventCallback + 46
30 CoreFoundation 0x01733d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
31 CoreFoundation 0x01733a9b __CFRunLoopDoSource1 + 523
32 CoreFoundation 0x0175e77c __CFRunLoopRun + 2156
33 CoreFoundation 0x0175dac3 CFRunLoopRunSpecific + 467
34 CoreFoundation 0x0175d8db CFRunLoopRunInMode + 123
35 UIKit 0x002a7add -[UIApplication _run] + 840
36 UIKit 0x002a9d3b UIApplicationMain + 1225
37 uConnect 0x000026fd main + 141
38 libdyld.dylib 0x01df670d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The app delegate code mentioned in the output:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch. WE CHECK IF THEY ARE ALREADY LOGGED IN OR NOT.
self.mainViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"UconnectViewController"];
self.navigationController = [[UINavigationController alloc]
initWithRootViewController:self.mainViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
// Open the session
[self openSession];
} else {
//Display login view
[self showLoginView];
}
return YES;
}
Here is the other function.
-(void)showLoginView
{
UIViewController *topViewController = [self.navigationController topViewController];
UIViewController *presentedViewController = [topViewController presentedViewController];
//-If login screen is not displayed display it.
//-If the login screen is displayed and we come back here then login failure.
//-Update UI if the second happens
if (![presentedViewController isKindOfClass:[UConnectLoginViewController class]]) {
UConnectLoginViewController* login = [[UConnectLoginViewController alloc] initWithNibName:@"UConnectLoginViewController" bundle:nil];
[topViewController presentViewController:login animated:NO completion:nil];
} else {
UConnectLoginViewController* login = (UConnectLoginViewController*) presentedViewController;
[login loginFailed];
}
}
OK, Maybe the problem is that you forget to put "URL types" in your Info.plist
I hope that this will help you4