© Wallace Wang 2017

Wallace Wang, macOS Programming for Absolute Beginners, 10.1007/978-1-4842-2662-9_7

7. Making Decisions with Branches

Wallace Wang

(1)San Diego, California, USA

After a program receives data, it needs to manipulate that data somehow to return a useful result. Simple programs manipulate data the same way, but more complicated programs need to make decisions on how to manipulate that data.

For example, a program might ask the user for a password. If the user types in a valid password, then the program gives the user access. If the user does not type in a valid password, then the program must display an error message and block access.

When a program analyzes data and makes a decision based on that data, it uses things called Boolean ...

Get macOS Programming for Absolute Beginners: Developing Apps Using Swift and Xcode now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.