NSUserNotificationCenter.default declared non-null but returns null
Originator: | dmaclach | ||
Number: | rdar://43645642 | Date Originated: | 23-Aug-2018 09:12 AM |
Status: | Open | Resolved: | |
Product: | macOS + SDK | Product Version: | 10.13 |
Classification: | Security | Reproducible: | Always |
Summary: NSUserNotificationCenter.default is declared as a non-null property but returns null. Furthermore Swift seems happy with it and doesn’t throw any errors. Steps to Reproduce: Run this swift script (attached) —————————— #!/usr/bin/swift import Foundation let notification = NSUserNotification() notification.title = "Wow" let center = NSUserNotificationCenter.default center.deliver(notification) ——————— Expected Results: I would expect NSUserNotificationCenter.default to throw an exception because I would argue that it is programmer error to be trying to get a UserNotificationCenter for a script/app/whatever that doesn’t have a bundle ID. (It appears that having a bundle ID is a prerequisite to being able to send notifications). The fact that it returns null breaks the nullability contract on NSUserNotificationCenter.default. Furthermore I would expect the swift side of things to error when I attempted to use the returned “center”. Actual Results: Center gets returned NULL. center.deliver does not crash and there is no indication that anything failed. Version: 10.13 Notes: GOOGLER:dmaclach
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!