我将UIButton
添加到其他UIViewController
的视图中。我需要目标选择器从json值
- (IBAction)timeline:(id)sender {
if ([_NoTimeline isEqualToString:@"timeline not available :)"]) {
NearmeNOViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"NONearmeViewController"];
[self presentViewController:vc animated:YES completion:nil];
} else {
NearmeFrendViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"NearmeFrendViewController"];
[self presentViewController:vc animated:YES completion:nil];
}
}
答案 0 :(得分:0)
如果时间轴不可用,您可以在此处将NSString
"timeline not available :)"
分配给变量self.NoTimeline
。并将NSArray
分配给变量self.NoTimeline
。如果您可以正确编辑您的api添加状态密钥。如果不试试这个
- (IBAction)timeline:(id)sender{
if ([self.NoTimeline isKindOfClass:[NSString class]]) {
NearmeNOViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"NONearmeViewController"];
[self presentViewController:vc animated:YES completion:nil];
}
else {
NearmeFrendViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"NearmeFrendViewController"];
[self presentViewController:vc animated:YES completion:nil];
}
}
答案 1 :(得分:0)
这里的问题似乎是_NoTimeline并不总是NSString类型。因此isEqualToString:操作失败。
您可以使用以下方法检查NSString:
if ([_NoTimeline isKindOfClass:[NSString class]] {
// Your code
}