以下代码有什么问题。它与SIGABRT崩溃(无法识别的选择器发送到实例)
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSLog(@"%@",valueName);
if([segue.identifier isEqualToString:@"pushView"])
{
secondViewController *svc = (secondViewController *)[segue destinationViewController];
svc.passedName = valueName;
}
}
valueName iVar是我要传递的NSString。
答案 0 :(得分:0)
1)请勿忘记FirstViewController
NavigationController
2)不要忘记设置您的segue标识符。
3)使用相同的代码:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//for example if you value is "123"
NSString *valueName = @"123";
NSLog(@"%@",valueName);
if([segue.identifier isEqualToString:@"pushView"])
{
secondViewController *svc = (secondViewController *)[segue destinationViewController];
svc.passedName = valueName;
}
}
4)现在,在secondViewController
中,在[{1}}中记录您的值,看看它是否已通过......
ViewDidLoad
5)您应该得到的结果: