简体   繁体   中英

Terminating app due to uncaught exception 'NSInvalidArgumentException' unrecognized selector sent to instance

I am new to xcode kindly help me to correct the error my code is below,

-(void)XYZ:(NSString *)id1
{
    id2 = [id1 intValue];
    [self Vehicles:id2];

}

-(NSArray *)Vehicles:(NSInteger) id2
{

    NSString *urlString=[NSString stringWithFormat:@"http://www.xxxx.com/xxxx/vehiclelist.php?uid=%d&format=json",id2];
    NSURL *url=[NSURL URLWithString:urlString];
    NSData *data=[NSData dataWithContentsOfURL:url];
    NSError *error;
    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
    NSArray *results = [json valueForKey:@"posts"];
    return results;
}

And i pass the id value from the login vied controller the code is,

if(stat!=0&&id2!=0&&[Username length]!=0&&[Password length]!=0)
{
    Services *loc = [[Services alloc] initWithNibName:@"Services" bundle:nil]; 
    loc.modalPresentationStyle = UIModalPresentationCurrentContext;
    loc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:loc animated:YES completion:Nil];
    MyVchicle *about = [[MyVchicle alloc]  initWithNibName:@"MyVchicle" bundle:nil];
    about.modalPresentationStyle = UIModalPresentationCurrentContext;
    about.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:about animated:YES completion:Nil];
    [loc XYZ:id1];
}

Thanks in advance.

For sending data from one ViewController to another, follow these steps :

  1. Declare a variable in your DestinationViewController.
  2. Connect a segue from your SourceViewController to your DestinationViewController.
  3. Now in your SourceViewController, write this function :
  -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { DestinationViewController *destController = [segue destinationViewController]; destController.varName = @"passThisValue"; } 
  1. The above function declares your destinationViewController and assigns a value to the variable of the destinationViewController that we declared above.

This should get you going. Hope this helps.

You can refer to this link.

Passing Data between View Controllers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: -[__NSCFString scheme]: unrecognized selector sent to instance Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType next]: unrecognized selector sent to instance ' Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString size]: unrecognized selector sent to instance Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectForKey:]: unrecognized selector sent to instance IOS - Terminating app due to uncaught exception 'NSInvalidArgumentException unrecognized selector sent to instance 0x7a9a2c0' Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray length]: unrecognized selector sent to instance *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM Name]: unrecognized selector sent to instance Terminating app due to uncaught exception 'NSInvalidArgumentException' unrecognized selector sent to instance Objective-C Singleton Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_.AppDelegate add:]: unrecognized selector
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM