Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Nicolaus Nsarray
Courses Plus Student 65 PointsNavigation Controller between view controller and table view controller
Any ideas on how to add a Navigation Controller in iOS7 between a Table View and View Controller. As soon as I embed the Navigation Controller to the table view the app crashes. With out the navigation controller it works fine. But then the Table View becomes a View Controller. This is the code I'm using:
[self.navigationController performSegueWithIdentifier:@"setup" sender:self];
10 Answers

Thomas Nilsen
14,957 PointsIf you have it - What does your prepareForSegue method look like?

Nicolaus Nsarray
Courses Plus Student 65 PointsHere is my storyboard:
http://sv.tinypic.com/r/1ztdnb/8
This is the code:
<p>
- (IBAction)signup:(id)sender {
NSString *username = [self.usernameField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *password = [self.passwordField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *email = [self.emailField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([username length] == 0 || [password length] == 0 || [email length] == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Please try again."
message:@"Make sure you enter all fields."
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
else {
PFUser *newUser = [PFUser user];
newUser.username = username;
newUser.password = password;
newUser.email = email;
[newUser signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry!"
message:[error.userInfo objectForKey:@"error"]
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
else {
[self.navigationController performSegueWithIdentifier:@"setup" sender:self];
}
}];
}
}
</p>
```

Thomas Nilsen
14,957 Pointsremove that:
else {
[self.navigationController performSegueWithIdentifier:@"setup" sender:self];
}

Nicolaus Nsarray
Courses Plus Student 65 PointsBut how do I get to the next controller then?

Thomas Nilsen
14,957 PointsIf your segue is connected from the "Sign Up" button, and it's a push-segue you don't need it. I should have explained a bit instead of just showing code.
Take a look at this example: https://www.dropbox.com/sh/otilgs627pksjke/p2II6Sk2Dh

Nicolaus Nsarray
Courses Plus Student 65 PointsThanks man. Do you have the whole project so I can try it out?

Thomas Nilsen
14,957 PointsWhat do you mean? That was just something I made to make it easier to understand :)

Nicolaus Nsarray
Courses Plus Student 65 PointsYes. But you cant open the project with only one file. Everything is missing

Thomas Nilsen
14,957 PointsThat's strange. I can mail it to you. What's your email?

Nicolaus Nsarray
Courses Plus Student 65 PointsThanks it worked out anyway