From e0ffe5ea5eb41491402578fae54d708fcfa36612 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 29 Sep 2022 19:33:46 +0000 Subject: [PATCH] Update 'Home' --- Home.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Home.md b/Home.md index f897330..afee0e7 100644 --- a/Home.md +++ b/Home.md @@ -452,7 +452,10 @@ Swift is strongly-typed, so we need to use the same number type for every argume ## Building the menu -Back in our `updateIcon()` function, we're first going to create a new dictionary to hold our filter results. Then we're going to populate this dictionary by calling [`Dictionary.filter()`](https://developer.apple.com/documentation/swift/dictionary/filter(_:)) with our fitler function, `findPhase()`. +Back in our `updateIcon()` function, we're first going to create a new dictionary to hold our filter results. Then we're going to populate this dictionary by calling [`Dictionary.filter()`](https://developer.apple.com/documentation/swift/dictionary/filter(_:)) with our filter function, `findPhase()`. + +We can use the special variable `$0` to access the array element currently running through our `findPhase()` filter function. Since our function takes [`Double`](https://developer.apple.com/documentation/swift/double) numbers as arguments, we'll convert the string value in `phaseArray` to a [`Double`](https://developer.apple.com/documentation/swift/double) - this is why we used [`NSString`](https://developer.apple.com/documentation/foundation/nsstring) instead of [`String`](https://developer.apple.com/documentation/swift/string) as the values in `phaseArray`. + ```swift @objc func updateIcon() { ...