Notice user and terminate the program when exit button is pressed. Ask yes or no. Yes to close the app. No to continue the program

Language: Objective C

Just like the title, I wanna implement the functionality that can keep user from clicking the exit button by mistake.

And it should show some words together like this:

"Do you want to close the program?" Button "Yes", Button "No"

Is any method I can use? Thank in advance.

Where should I put this code?And how to make the actions of those buttons in alert window?

iOS or MacOS ?

Notice user and terminate the program when exit button is pressed. Ask yes or no. Yes to close the app. No to continue the program
 
 
Q