Day 18‘s lesson is Day 3 of 3 of the first iOS project named Project1 (aka “Storm Viewer” app).
Day 18’s lesson is named Project 1, part three and it consisted of two things: a review (in the form of a 12 questions test) about what was learned in Project 1, and a coding challenge that involved implementing three new features/functionality to the Project 1 Storm Viewer app.
Thoughts about Day 18
I completed the 12 questions Review section first. In the previous Days’ lessons I dreaded doing the review questions part of the lesson. The review questions felt like a tedious chore to me. Now I’ve grown to appreciate the review questions and find them a valuable learning aid.
The three Storm View app coding challenge objectives:
- Objective: Use Interface Builder to select the text label inside your table view cell and adjust its size to something larger – experiment and see what looks good.
- My solution: Using Interface Builder I went to Main.storyboard > Table View > Title > Attribute Inspector. After exploring and experimenting with the different Label Font choices I went with choice “Title 1”, because that font size resulted in displaying only all 10 filenames on the screen.

- Objective: In your main table view show the image names in sorted order, so “nssl0032.jpg” comes before “nssl0034.jpg”
- My solution: In the ViewController.swift file I noticed that the pictures variable used the .append(item) method. As a test, I added a new line containing the pictures variable name and then I appended the dot (“.”) operator after it to see a pop-up listing of methods associated to the variable. I saw a sort( ) method and selected it, then I moved the pictures.sort( ) line above the existing line of print(pictures) (which prints the image filenames to xCode’s debug output window). Next, I launched the Storm Viewer app and checked in the debug output window the order in which the image filenames were listed. It was in the sorted order that I needed, which also displayed in the sort order that I needed in the app’s main screen.

- My solution: In the ViewController.swift file I noticed that the pictures variable used the .append(item) method. As a test, I added a new line containing the pictures variable name and then I appended the dot (“.”) operator after it to see a pop-up listing of methods associated to the variable. I saw a sort( ) method and selected it, then I moved the pictures.sort( ) line above the existing line of print(pictures) (which prints the image filenames to xCode’s debug output window). Next, I launched the Storm Viewer app and checked in the debug output window the order in which the image filenames were listed. It was in the sorted order that I needed, which also displayed in the sort order that I needed in the app’s main screen.
- Objective: Rather than show image names in the detail bar, show “Picture X of Y” where Y is the total number of images and X is the selected picture’s position in the array. Make sure you count from 1 rather than 0.
- My solution: In DetailViewController.swift I added two new variables to hold the value of the total number of pictures in the pictures array and the selected image’s position in the pictures array. I also updated the title line to display in the Detail view’s heading the text “Picture \(selectedImage) is \(selectedImagePositionInArray) of \(totalNumberOfPictures)“

- Then in ViewController.swift I used the existing line vc.selectedImage = pictures[indexPath.row] as the example code to follow, and then I added two lines that assigned values to the totalNumberOfPictures and selectedImagePositionInArray variables.

- Despite it being quick and simple to add the above five new code lines, it took me 1 hour and 40 minutes to figure out where the code changes needed to be made and how to write the code to implement the functionality for “show ‘Picture X of Y’ where Y is the total number of images and X is the selected picture’s position in the array.“
- My solution: In DetailViewController.swift I added two new variables to hold the value of the total number of pictures in the pictures array and the selected image’s position in the pictures array. I also updated the title line to display in the Detail view’s heading the text “Picture \(selectedImage) is \(selectedImagePositionInArray) of \(totalNumberOfPictures)“
It took me 3 hours of actual focused study time to complete the Day 18 lesson, with 2 hours 40 minutes of that time spent on solving the the three-objectives challenge.
Today’s study time*: 3 hours
100 Days of Swift cumulative study time: 52 hours 20 minutes
[*Note: those are actual study time values after subtracting break-time minutes from the Day’s study session]