Updated sample code to adopt the Swift 5 syntax and changes in the macOS 10.14 SDK


#1

:tada: Updated sample code of the book that adopts the Swift 5 syntax and changes in the macOS 10.14 SDK can be found here:
https://github.com/LumingYin/cocoa-programming-for-macos-5e-swift5

All projects and Playgrounds (including intermediate project in each chapter’s folder) are:

  • Migrated to Swift 5 syntax
  • Builds with no errors or warnings on the latest toolchain with the macOS 10.14 SDK
  • Behaves and runs correctly on macOS 10.14 as intended by the original author

Specific changes in ImageTiling:

  • Disables translatesAutoresizingMaskIntoConstraints, which are enabled by default on newer versions of macOS, so that scroll views have the correct content sizes

Specific changes in RaiseMan, CarLot and ZIPspector:

  • Add necessary explicit @objc annotation to remove reliance on deprecated inference rules
  • Explicitly call Swift.print() instead of print() to avoid runtime exceptions

Specific changes in RanchForecast and RanchForecastSplit:

  • Enabled NSAllowsArbitraryLoads under NSAppTransportSecurity so that the app would load data
  • Fixed WebViews so that they no longer default to zero-width when running on macOS 10.12 or above