0

In the userInfo of my notification, there is an error key, which contains an NSError

however casting it to Error fails and NSError successes

This code does NOT pass

        guard let error = notification.userInfo?["error"] as? Error else {
            return
        }

This code passes

        guard let nserror = notification.userInfo?["error"] as? NSError else {
            return
        }
        
        guard let error = nserror as? Error else {
            return
        }

I see no reason for such oddness, besides a bug in Swift? can somebody share some light on this?

Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179

0 Answers0