tip of the iceberg. Go more in depth by researching the options parameter animate(withDuration:delay:animations:). Look at common pitfalls regarding animations, e.g. your app’s process being interrupted causing the animation to fail.
a global variable can have disastrous effects. Sometimes the alternative to have every class keep a property. Also there are times when you want a variable to change without the class that uses it to have to do any work.
access the singleton’s themeColor property and set the view’s background color as such. Any singleton that’s an object should be checked for existence before use.
by title or distance. Swift has powerful sorting capabilities. But first let’s distinguish between sort() and sorted() with a playground. present tense verbs like ‘sort()’ are mutating functions - they permanently change the collection. Past tense verbs like ‘sorted()’ will make copies. Here we sort alphabetically from lowest to highest from the top of the table (the 0th index).
get the table sorted by distance from highest to lowest. Notice that ‘title’ and ‘distance’ are completely different types. Under the hood, sort() determines the type and goes from there.
store id’s, but how to inform our favorites view that a new location is favorited? The are several ways but we’ll use the cascading pattern which leverages our custom tab bar to propagate the change.
handle navigation in iOS: 1) UITabbarController which handles the overall structure of our app. 2) Modal presentation which handled the details of our locations UINavigationController which we’ll see next, is the third common way to handle navigation iOS.