How to code an alert in OS X (10.12.1) and Xcode 8.1 using Swift 3?

I'm running OS X (10.12.1), Xcode 8.1 and Swift 3 on my MacBook Pro (all are updated automatically). For a MacOS application (not iOS), I want to show an alert when an invalid user entry is input. I've researched a zillion examples and tried many of them, but none work. And, a good number of them send my Playground into a loop (dreaded color wheel) from which I have to reboot (the latest of these is attached).


My question is: What is the proper Swift 3 code to create an alert in the environment and the conditions described above occur?

You shouldn't need to reboot to kill Xcode. Did you try right-clicking on Xcode icon in the dock and picking Force Quit?


If you're attaching images to your posts here, it's a waste of time; the forum does not display images. You can post links to images.

goldsdad, thanks for the 'force quit' for Xcode tip. It works and saves a lot of time!. I'll link the code in another reply.

How to code an alert in OS X (10.12.1) and Xcode 8.1 using Swift 3?
 
 
Q