Basic debugging practices
When programming an app, you will no doubt encounter many little snags along the way. After some time, you might not even notice some of the smaller issues you run into because of how quickly you can resolve them. In this section, we'll look at some of the most basic ways to look at what is going on inside your app so that you can navigate around the issues you may encounter.
print()
Sometimes, the simplest answer is the best answer. Using a print statement to write a string out to the console can be a quick and effective way to get a status report from inside your app. The print()
function is defined in the Swift standard library of functions, and lets you write strings to the console with some minor formatting options:
print("hello world!")
The print function, while usually used to print a single string, can also accept several string parameters to print, along with a separator and a terminator string:
print("apple","orange","...