Showing posts from November, 2019

UIAppDelegate and SceneDelegate accessing variables

As you likely know iOS 13 introduced the multiple window concept. Which means what you used to do with(UIApplication.shared.delegate as! AppDelegate).somevariableHERE No longer works and I am happy to tell you that you can still do it just slightly different. And in my opinion clearer.

(self.window?.windowScene?.delegate as! SceneDelegate).someOtherVariableHere ReferencesApple usual bare-extreme-bone docs Background

Coordinator Pattern for iOS 12 and 13

As the awesome Swift master Paul puts it:Using the coordinator pattern in iOS apps lets us remove the job of app navigation from our view controllers, helping make them more manageable and more reusable, while also letting us adjust our app's flow whenever we need. It is a darn useful pattern and something that since I learned about it, I used it in all my apps. Paul also released an advanced version as well of the original tutorial.

Patrick has a slightly different implementation of the same pattern and although I prefer Paul's approach (only slightly different in character) there are some nuances in his post that are definitely worth reading.

All that magic is challenged with iOS 13 because of the introduction of the UISceneDelegate. I hammered my head a few times before I got the clue of what had to be changed given that the window object is now no longer created in the AppDelegate but the SceneDelegate.

Mark describes the difference very well in this post. Something that I fa…