Post

Replies

Boosts

Views

Activity

Reply to How do I use async/await with NotificationCenter?
I figured out what was wrong with it: this was what I was doing: for await _ in NotificationCenter.default.notifications(named: UIDevice.orientationDidChangeNotification, object: self) { print("orientation changed") // This would never fire } I changed it to: for await _ in NotificationCenter.default.notifications(named: UIDevice.orientationDidChangeNotification) { print("orientation changed") // This works } I guess I misunderstood what that object param was used for.
Topic: Community SubTopic: Apple Developers Tags:
Nov ’21
Reply to AppDelegate can be nil?
I actually ran into an example of UIApplication.shared.delegate being nil today. During the init of your app delegate, UIApplication.shared.delegate is nil. So if something needs to access the app delegate immediately after super.init() there's a possibility its still nil. For me, I populated my dependency root for dependency injection here. I added a line of code to one of my services that needed to access the app delegate and it was nil. Other than this, I can't think of any other possible times that it would be nil.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’20