Pressing stop button and get Program ended with exit code: 9

Hi!

When I press the stop button during a running program in Xcode, I get the output "Program ended with exit code: 9".

What should I write in the code in order to exit the program safely, i.e. so the program ends with exit code 0 when pressing the stop button during a running session?
Do you mean you stop the program on simulator ?
That's not a normal stop of the app, so its logical to get an error exit.

Which version of Xcode ?

And why is it a problem to have such an exit ?
Pressing stop button and get Program ended with exit code: 9
 
 
Q