Code upgrade

In attempting to replicate the demonstration app from this lesson, I ran across a piece of code which did not seem to be allowable; I’m guessing that this may be because my version of XCode is 12.3, rather than 12.2 as in the instructor’s demonstration.

    // Lecture example in class had:
    // ... (for: normal)
    // which no longer seems to be an option.
    // Change in Xcode 12.3 from 12.2?
    let title = (sender as AnyObject).title(for:
        UIControl.State(rawValue:
        UIControl.State.RawValue(FP_NORMAL)))

UPDATE 210115: Disregard the above! It turns out that the correct code is

... (for: .normal)

I had forgotten the full stop/period!! But I’m going to leave this here as it demonstrates how a small detail can create a big problem.

Creating icons

Every professional app should have suitable icons. Here are the steps to do this:

  1. Create a large icon (say, 1024×1024)—since graphics can be downsized but not upsized without interpolation algorithms, and the result would likely be messy—in .png or .jpg format.1)Remember that .png allows for transparency! I typically use GIMP for this sort of thing.
  2. In the Navigation Panel, click on the Assets.xcassets folder; here you can see the various sizes you will need.
  3. Use Preview to import the large icon, and > Tools to create smaller sized versions. Of course, if the large icon was created with GIMP, one may as well use the image resizing tool there….2)I’ve read some threads which suggest using ImageMagick instead. I’m looking into it; it certainly would be easier to have a batch file which can create all needed icons from a master! As a minimum, one should create the following (XCode will interpolate the others as required):
    1. 180 x 180
    2. 120 x 120
    3. 87 x 87
    4. 80 x 80
    5. 58 x 58
  4. Drag the various icons to the appropriate places in the assets folder.

UPDATE 210115: I’m looking at putting together a Script-fu script for GIMP to take an icon and produce all the necessary icon sizes automatically.3)I’m working on a tutorial at the moment. But if someone beats me to it, let me know!

Launch screen

Remember to create a launch screen, as this will display while the app is loading. This can make a difference to the user experience if/when the app takes a while to load.

This is quite simple to do:

  1. the Navigation Panel, click on LaunchScreen.storyboard.
  2. Place a label with text, an image, or whatever you would like the user to see while the app is loading.

Notes

Notes
1 Remember that .png allows for transparency!
2 I’ve read some threads which suggest using ImageMagick instead. I’m looking into it; it certainly would be easier to have a batch file which can create all needed icons from a master!
3 I’m working on a tutorial at the moment.