I have a pickerview with 2 components, I have a 3 button segmented control. Based on what the user selects between the pickerview and the segmented control, I have a UILabel that displays a string. I wo开发者_StackOverflow中文版uld like to push a view controller based on what is displayed in the UILabel. Should I use a switch statement for this? How do I convert the string values into integer expressions for the switch statement to work?
switch (fooLabel.text) {
case @"foo-bar":
[self.navigationController pushViewController:exampleVC animated:YES];
break;
default:
break;
}
thanks!
just use multiple if statements
if ([fooLabel.text isEqualToString:@"foo-bar"])
{
//Show one
}
else if ([fooLabel.text isEqualToString:@"bar-foo"])
{
//Show Other
}
else
{
//Show Default
}
精彩评论