簡體   English   中英

由於未捕獲的異常'NSInvalidArgumentException'無法識別的選擇器發送到實例而終止應用程序

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

我是xcode的新手,請幫助我糾正下面的錯誤,

-(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;
}

我從登錄競爭控制器傳遞ID值,代碼是,

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];
}

提前致謝。

要將數據從一個ViewController發送到另一個,請按照以下步驟操作:

  1. 在DestinationViewController中聲明一個變量。
  2. 將序列從SourceViewController連接到DestinationViewController。
  3. 現在在您的SourceViewController中,編寫以下函數:
  -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { DestinationViewController *destController = [segue destinationViewController]; destController.varName = @"passThisValue"; } 
  1. 上面的函數聲明您的destinationViewController,並為我們上面聲明的destinationViewController的變量分配一個值。

這應該可以幫助您。 希望這可以幫助。

您可以參考此鏈接。

在視圖控制器之間傳遞數據

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因:-[__ NSCFString方案]:無法識別的選擇器已發送到實例 由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因:'-[__ NSCFType next]:無法識別的選擇器已發送至實例' 由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因:'-[__ NSCFString size]:無法識別的選擇器已發送到實例 由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因:'-[__ NSArrayM objectForKey:]:無法識別的選擇器已發送至實例 iOS-由於未捕獲的異常'NSInvalidArgumentException無法識別的選擇器發送到實例0x7a9a2c0'而終止應用程序 由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因:'-[__ NSCFArray length]:無法識別的選擇器已發送到實例 ***由於未捕獲的異常“ NSInvalidArgumentException”而終止應用程序,原因:“-[__ NSDictionaryM名稱]:無法識別的選擇器已發送到實例 由於未捕獲的異常'NSInvalidArgumentException'無法識別的選擇器發送到實例Objective-C Singleton而終止應用程序 由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因:'-[NSNull長度]:無法識別的選擇器已發送到實例 由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因:'-[_._ AppDelegate add:]:無法識別的選擇器
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM