假设我有这个代码:
if ([resultButton.titleLabel.text isEqualToString:@"Tax"]) {
TAXViewController *controller = [[TAXViewController alloc]initWithNibName:@"TAXViewController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:controller animated:YES completion:nil];
[controller release];
}else if ([resultButton.titleLabel.text isEqualToString:@""]){
RENTViewController *controller = [[RENTViewController alloc]initWithNibName:@"RENTViewController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:controller animated:YES completion:nil];
[controller release];
}else if //repeats a lot......
我想在多个 .h 文件中使用相同的代码。有没有一种方法可以编写代码(仅在一个地方)并从其他 .h 文件访问它而无需到处重复?
所以最后我猜,我可以将一个字符串传递给其他 .h/.m 文件,它会打开带有匹配字符串的视图。