【发布时间】:2011-03-17 07:07:48
【问题描述】:
例如,
在您的程序中,您有:
NSLog(@"Where are you going?");
NSLog(@" 1 = Location1, 2 = Location2");
printf("Make a selection:");
scanf("%i, &value);
switch (value) {
case 1:
NSLog(@"You are going to Location 1.")
break;
case 2:
NSLog(@"You are going to Location 2.");
break;
default:
NSLog(@"That is not a valid location");
break;
}
通常在您输入整数后,您的程序将返回 0 并且应用程序结束。你如何让它“循环”回到原来的 printf 以做出新的选择。或者更好的是,一个新的 printf IE 'printf("你还想去哪里?:");'?
【问题讨论】:
标签: objective-c xcode ios loops switch-statement