答案 0 :(得分:3)
尝试将方法签名更改为
- (void)switchViewTo:(NSString *)view
{
if ([view isEqualToString:@"view1"]) {
NSLog(@"view 1");
} else if ([view isEqualToString:@"view2"]) {
NSLog(@"view 2");
} else {
NSLog(@"whatever");
}
}
在指定的初始值设定项中,您调用[self switchToView:@"view1"];