Search code examples
iosobjective-cuiviewcontrolleruitextfielduistoryboardsegue

Error when performing segue: -[UITextField length]: unrecognized selector sent to instance


I have some code to change to another screen in my app:

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data {
    NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    NSLog(@"Performing Segue...");
    // Open detail segue
    [self performSegueWithIdentifier:@"DetailViewSegue" sender:dataString];
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)json
{
    NSLog(@"Testing...");
    // If we are going to the success view, send the JSON data over as well!
    if ([segue.identifier isEqualToString:@"DetailViewSegue"]) {
        DetailViewController *DetailViewControllerSegue = [segue destinationViewController];
        NSDictionary *jsonSendetAsParamInPerformSegue = (NSDictionary*)json;
        DetailViewControllerSegue.jsonString = jsonSendetAsParamInPerformSegue;

    }
}

When I attempt to perform the segue I get this error: -[UITextField length]: unrecognized selector sent to instance 0x14589970

What does error mean? And how can I resolve it?

Thanks,

Peter


Solution

  • The reason this error appeared was because I had a typo in my Storyboard Segue Identifier and it didn't match:

    @"DetailViewSegue"
    

    in:

    [self performSegueWithIdentifier:@"DetailViewSegue" sender:dataString];
    

    I hope this helps others in the future

    Peter