2014-06-23 125 views
0

我想通過兩個視圖之間的日期/字符串,但我不知道它。通過日期之間的意見

我的代碼

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ 
    if ([[segue identifier] isEqualToString:@"pasa_codigo"]) { 
     Formulario *segundoView = [segue destinationViewController]; 
     segundoView.nombre = [input_codigo text]; 

    } 
} 

的錯誤: 「原因:「 - [UIViewController中setNombre:]:無法識別的選擇發送到實例」

回答

0

的​​應該是物業在Formulario類。而且你還需要輸入[segue destinationViewController]Formulario類。

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ 
    if ([[segue identifier] isEqualToString:@"pasa_codigo"]) { 
     Formulario *segundoView = (Formulario *)[segue destinationViewController]; 
     segundoView.nombre = [input_codigo text]; 

    } 
} 
0

什麼正從[seque destinationViewController];返回是UIViewController所以嘗試鑄造它。所以用這個Formulario *sequndoView = (Formulario *)[seque destinationViewController];

是因爲[seque destinationViewController];剛剛返回UIViewController取代,當你嘗試做segundoView.nombre = [input_codigo text]它試圖呼籲的UIViewController實例的集合,但UIViewController不具有​​的財產,只有Formulario屬性所以這就是類型轉換的原因。

0

在IB改變類名的UIViewController到Formulario

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ 

    if ([[segue identifier] isEqualToString:@"pasa_codigo"]) { 

     UIViewController *segundoView = [segue destinationViewController]; 

     if ([segundoView isKindOfClass:[Formulario class]) { 

      segundoView.nombre = [input_codigo text]; 

     }else{ 
      //For Debugging print the view controller to know the name of the destination     
      NSLog(@"Which view controller is Destination : %@",segundoView); 
     } 


    } 
} 

但你仍是朝向碰撞,然後驗證「農佈雷」屬性在Formulario.h文件中聲明。

@property(nonatomic,retain)NSString *nombre;