Reputation: 21
I coded two segues from one view controller to two viewcontrollers. When I activate one segue it works. When I activate the other segue it crashes because of a variable that is into the former viewcontroller. In particular, when I push for the SegueToK2 it crashes because of a variable (passingK3) that is into the other viewcontroller. *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ABGPotassiumViewController2 setPassingK3:]: unrecognized selector sent to instance 0x108026a00'
-(IBAction)sceltaSelettoreECG:(id)sender{
if (_ChooseECG.selectedSegmentIndex==0) {
[self performSegueWithIdentifier:@"SegueToK2" sender:self];
}
if (_ChooseECG.selectedSegmentIndex==1) {
[self performSegueWithIdentifier:@"segueToK3" sender:self];
}
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if([[segue identifier] isEqualToString:@"SegueToK2"])
{ //segue alla view potassio2
ABGPotassiumViewController2 *destination=[segue destinationViewController];
{
destination.passingK2=_passingK1;
destination.passingLanguageK2=_passingLanguage2;
destination.Therapy1=[NSString stringWithFormat:@"\nSomministra in bolo ev Calcio Gluconato 1 g (10 ml di soluzione al 10%%)\n"];
destination.Therapy2=[NSString stringWithFormat:@"\nRipeti ECG dopo 5 minuti\n"];
destination.Therapy3=[NSString stringWithFormat:@"\nSe persistono le alterazioni dell'ECG somministra altro calcio gluconato\n"];
}
}
//segue alla view potassio3
if
([[segue identifier] isEqualToString:@"segueToK3"])
NSLog(@"sono arrivato a segue k3");
{
ABGPotassium3ViewController *destination=[segue destinationViewController];
{
destination.passingK3=_passingK1;
}
}
}
I tried to search for the variable passingK3 but I found it is only in these lines. The same for the viewController. I blocked the code before the segueToK3 and it works, but as I put the block on the 'if' of the segueToK3 it crashes again with the same reason
Upvotes: 1
Views: 21
Reputation: 21
Found the problem! Don't know how it is possible, but it was selected @destination of the segue settings 'detailed split' instead of Current. I set Current and both the segues work well. Waste a lot of time to solve this stupid problem!!
Upvotes: 1