Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8642097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:41:27+00:00 2026-06-12T11:41:27+00:00

I am trying to do a conditional segue. But I get: Terminating app due

  • 0

I am trying to do a conditional segue. But I get:

    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILabel length]: unrecognized selector sent to instance 0x763c8e0'

The design is, when I pressed a button, the app will retrieve some data from the internet using AFNetworking’s AFJSONRequestOperation. If the request succeed, it will call another UIViewController from my current UIViewController. I did my conditional start segue using this method and below are my codes:

-(void) login:(NSString*)pinString{    
NSString* urlString = [NSString stringWithFormat:@"%@%@%@", [super.serverResource getURL], [super.serverResource getRequestByKey:@"login"] ,pinString];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];    
AFJSONRequestOperation *operation = [MenuletJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    [self performSegueWithIdentifier:@"login" sender:self];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){
    switch([response statusCode]){
        case (403):{
            UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Log in failed"
                                                      message:@"Log in denied, check your PIN."
                                                      delegate:nil cancelButtonTitle:@"OK"
                                                      otherButtonTitles:nil];
            [alert show];
            break;
        }
    }
}];
[operation start];

}

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
SettingViewController *settingVC = (SettingViewController*)[storyboard instantiateViewControllerWithIdentifier:@"SettingViewController"];
[self presentViewController:settingVC animated:YES completion:nil];

}

And I get the exception above after “ViewDidLoad” excuted in SettingViewController. If I don’t use conditional segue, and simply ctl drag from the Button to SettingViewController on IB, everything works fine… please give me some suggestion… I am really out of ideas…

Below are my code from SettingViewController:

- (void)viewDidLoad{
[super viewDidLoad];
// Do any additional setup after loading the view.
//StringResources* resource = [[StringResources alloc]init];
[self.titleLabel setText:[super.stringResource getStringByKey:@"screen_setting_title"]];
[self.createOrderLabel setText:[super.stringResource getStringByKey:@"screen_setting_create_order_label"]];
[self.refreshMenuLabel setText:[super.stringResource getStringByKey:@"screen_setting_refresh_menu_label"]];
[self.tableNumberLabel setText:[super.stringResource getStringByKey:@"screen_setting_table_number_label"]];

}

Actually, I didn’t put much thing in SettingViewController, all I did was programatically setting some label. And I put breakpoint on each setText, and they all executed without error. So the exception must happened after ViewDidLoad…

This is where the error occur:

#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); //error occur here
    }
}

Solved… Turn out Segue handle everything. All I need to do is setup a generic segue. and once I called [self performSegueWithIdentifier:@”login” sender:self], everything works perfectly. Thank you everyone… (overriding prepareForSegue will only cause a problem…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:41:29+00:00Added an answer on June 12, 2026 at 11:41 am

    Option 1: Trust the segue

    Make sure the segue goes from your current view controller to SettingViewController.

    Then you keep -performSegueWithIdentifier:sender:.

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
       // load data from current view controller to segue.destinationViewController
    }
    

    Option 2: Manually load the modal view controller

    Throw away the segue all together and just load the view controller from the storyboard.

    AFJSONRequestOperation *operation = [MenuletJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        SettingViewController *settingVC = (SettingViewController*)[storyboard instantiateViewControllerWithIdentifier:@"SettingViewController"];
        // load data from current view controller to settingVC
        [self presentViewController:settingVC animated:YES completion:nil];
    } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){
        // Error handler
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do a conditional statement with Expression Language, but can't get it
We're trying to get a conditional attribute to work, case in point, there's a
I am trying to get the following ternary conditional to work in Asp.Net MVC
I am trying to use the conditional operator, but I am getting hung up
I am trying to use nested conditional statements in jade, but keep getting syntax
I'm trying to add some conditional open graph tags to my app, using current_page
I'm trying to get a simple conditional statement to work, and running into problems.
I'm trying to do conditional formatting so that the cell color will change if
I am using Oracle 11g client, with ODP.NET. I am trying to add conditional
I am trying to use the conditional (ternary) operator to assign the proper lambda

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.