Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Segue help

i was working on this app and it has been working really well and then i tried to run the app and didn't get why a segue didn't run as it is always suppose to do when the app opens. i then pressed a button that performs the same segue and the app would crash.

here is the error message:

2014-04-05 19:57:23.381 On Tour Company[4886:60b] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist. 2014-04-05 19:57:26.534 On Tour Company[4886:60b] Current user: (null) 2014-04-05 19:57:26.768 On Tour Company[4886:60b] Push notifications are not supported in the iOS Simulator. 2014-04-05 19:57:29.868 On Tour Company[4886:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<LoginViewController 0x9b43750> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key barSignUp.' *** First throw call stack: ( 0 CoreFoundation 0x02af11e4 exceptionPreprocess + 180 1 libobjc.A.dylib 0x023b48e5 objc_exception_throw + 44 2 CoreFoundation 0x02b80fe1 -[NSException raise] + 17 3 Foundation 0x02074d9e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282 4 Foundation 0x01fe11d7 _NSSetUsingKeyValueSetter + 88 5 Foundation 0x01fe0731 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267 6 Foundation 0x02042b0a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412 7 UIKit 0x0132b1f4 -[UIRuntimeOutletConnection connect] + 106 8 libobjc.A.dylib 0x023c67de -[NSObject performSelector:] + 62 9 CoreFoundation 0x02aec76a -[NSArray makeObjectsPerformSelector:] + 314 10 UIKit 0x01329d4d -[UINib instantiateWithOwner:options:] + 1417 11 UIKit 0x015d88bd -[UIStoryboard instantiateViewControllerWithIdentifier:] + 220 12 UIKit 0x015d8eb6 -[UIStoryboardSegueTemplate _perform:] + 88 13 UIKit 0x0119541c -[UIViewController performSegueWithIdentifier:sender:] + 72 14 On Tour Company 0x00007680 -[BlogTableViewController logout:] + 144 15 libobjc.A.dylib 0x023c6880 -[NSObject performSelector:withObject:withObject:] + 77 16 UIKit 0x010763b9 -[UIApplication sendAction:to:from:forEvent:] + 108 17 UIKit 0x013638df -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139 18 libobjc.A.dylib 0x023c6880 -[NSObject performSelector:withObject:withObject:] + 77 19 UIKit 0x010763b9 -[UIApplication sendAction:to:from:forEvent:] + 108 20 UIKit 0x01076345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61 21 UIKit 0x01177bd1 -[UIControl sendAction:to:forEvent:] + 66 22 UIKit 0x01177fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577 23 UIKit 0x01177243 -[UIControl touchesEnded:withEvent:] + 641 24 UIKit 0x010b5ddd -[UIWindow _sendTouchesForEvent:] + 852 25 UIKit 0x010b69d1 -[UIWindow sendEvent:] + 1117 26 UIKit 0x010885f2 -[UIApplication sendEvent:] + 242 27 UIKit 0x01072353 _UIApplicationHandleEventQueue + 11455 28 CoreFoundation 0x02a7a77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15 29 CoreFoundation 0x02a7a10b __CFRunLoopDoSources0 + 235 30 CoreFoundation 0x02a971ae __CFRunLoopRun + 910 31 CoreFoundation 0x02a969d3 CFRunLoopRunSpecific + 467 32 CoreFoundation 0x02a967eb CFRunLoopRunInMode + 123 33 GraphicsServices 0x02a1a5ee GSEventRunModal + 192 34 GraphicsServices 0x02a1a42b GSEventRun + 104 35 UIKit 0x01074f9b UIApplicationMain + 1225 36 On Tour Company 0x0000311d main + 141 37 libdyld.dylib 0x03642701 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

here is the code for the the first view controller in this set. in the view under view will load (using parse backend (this section of the app is almost identical to the self destructing message app's inbox and login)) i check who is logged into the app and if no one is it suppose to go to the log in screen. I dont know why it isn't.

'''objective-c

import "BlogTableViewController.h"

@interface BlogTableViewController ()

@end

@implementation BlogTableViewController

-(void) viewDidLoad { [super viewDidLoad]; [self.tabBarController.tabBar setHidden:NO];

}

-(void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.tabBarController.tabBar setHidden:NO];

PFUser *currentUser = [PFUser currentUser];
if ([currentUser  isEqual: @"nil"]) {
    [self performSegueWithIdentifier: @"logout" sender: nil];

}
else{
    NSLog(@"Current user: %@", currentUser.username);
}

}

pragma mark - Table view data source

  • (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    // Return the number of sections. return 1; }

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    // Return the number of rows in the section. return 1; }

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

    // Configure the cell...

    return cell; }

  • (IBAction)logout:(id)sender { [PFUser logOut]; [self performSegueWithIdentifier: @"logout" sender: nil];

} @end'''

and here just incase it helps is the code of the segue goes to. most of the code is related to logging in a user with a parse backend but here it is.

'''objective-c
#import "LoginViewController.h"

@interface LoginViewController ()

@end

@implementation LoginViewController

  • (void)viewDidLoad { [super viewDidLoad]; NSLog(@"Hello"); [self.tabBarController.tabBar setHidden:YES]; }

  • (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.usernameField resignFirstResponder]; [self.passwordField resignFirstResponder]; }

  • (IBAction)login:(id)sender { NSString *username = self.usernameField.text; NSString *password = [self.passwordField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

    if ([username length] == 0 || [password length] == 0) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops!" message:@"Make sure you enter a username and password!"delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];

    [alertView show];
    

    } else{ [PFUser logInWithUsernameInBackground:username password:password block:^(PFUser *user, NSError *error) { if (error) { UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Sorry!" message:[error.userInfo objectForKey:@"error"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alertView show]; } else{ [self.navigationController popToRootViewControllerAnimated:YES]; } }]; }

}

  • (IBAction)signUp:(id)sender {

}

@end'''

1 Answer

Pedro Fernandes
Pedro Fernandes
5,847 Points
 Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key barSignUp.' 

Reading this I suspect the error has to do with a typo in the string identifier for the segue.identifier barSignUp?