xcode - Objective-C: How to return to beginning of application after switch statement is complete -


For example,

In your program you have:

 < Code> NSLog (@ "Where are you going?"); NSLog (@ "1 = location1, 2 = location2"); Printf ("Select one:"); Scan ("% i, and value)" switch (value) {Case 1: NSLog (@ "You are Going to Location 1.") Break; Case 2: NSLog (@ "You're Going to Location 2.") ;; Break; Default: NSLog (@ "This is not a valid location"); Break;}   

Normally after your integer input your program returns 0 and the application will end you to return a "loop" to make a new selection to get the original printfase How can I say about returning Or even better, a new printf IE 'printf ("Where else would you like to go?");'?

Why do not you keep it as a separate method and when you want to loop it Make a call from yourself. Consider the following code,

  zero lemetoples () {NSLog (@ "Where are you going?"); NSLog (@ "0 = exit, 1 = location1, 2 = location2"); Printf ("Select one:"); Scanf ("% i" and value); Switch (Value) {Case 0: NSLog (@ "You Do not Want to Go Anywhere"); Breakdown; Case 1: NSLog (@ "You're Going to Location 1. "TakeMeToPlaces"; breakdown; Case 2: NSLog (@ "You are going to position 2."); TakeMeToPlaces (break); Default: NSLog (@ "This is not a valid location"); takeMeToPlaces ( ); Break;}}    

Comments