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! While you're at it, check out some resources Treehouse students have shared here.
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
Alex Atwater
2,624 PointsPerforming Manual Segue between Views
Can’t find answer anywhere! I have a view with a button and a text box on it. The text box is for numbers only, and i want the user the enter a number and then when the button is clicked, check to see if the value is less than 100, and if it is, move to the next screen by calling the manual segue. Everything is good (segue name matches up, less than 100 if statement is correct, etc) but what’s giving me an error is
[self performSegueWithIdentifier:@"nextScreen" sender:self];
throwing the error: -[FirstViewController editingEnded:]: unrecognized selector sent to instance 0x8b9e8e0 with instance 0x8b9e8e0 being “self”, specifically the very first self in that statement. I have no idea what is going wrong here or how to fix it. This is also a push segue. I watched Amit Bijlani segue video in the course, but this is a little more ambitious than what was taught...
Alex Atwater
2,624 Points#import "FirstViewController.h"
@interface FirstViewController ()
@end
@implementation FirstViewController
- (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.
self.percentField.alpha = 0;
self.percentLabel.alpha = 0;
self.nextButton.alpha = 0;
}
- (IBAction)yesButton:(id)sender {
self.percentField.alpha = 1;
self.percentLabel.alpha = 1;
self.nextButton.alpha = 1;
}
- (IBAction)nextPressed:(id)sender {
float textBoxValue = [[NSDecimalNumber decimalNumberWithString:self.percentField.text]floatValue];
if (textBoxValue > 105.00 || textBoxValue < 0.0) {
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Value Cannot Exceed 105.0%" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles: nil];
[errorAlert show];
self.percentField.text = @"";
} else {
NSLog(@"\nSuccess");
[self performSegueWithIdentifier:@"nextScreen" sender:self];
}
}
2 Answers
J Sherwani
248 PointsI'm pretty experienced with Objective-C, and while I haven't used segues, I'd be happy to help you via screen sharing on Screenhero. Feel free to add me:
Alex Atwater
2,624 PointsI found out that i had a bad IBAction connection that i deleted from code but not from IB
Stone Preston
42,016 PointsStone Preston
42,016 Pointscan you post your code for that view controller. I dont think its the segue thats causing the problem.