Type inconsistency of titleTextAttributes

Number:rdar://36179361 Date Originated:December 21 2017, 11:30 AM
Status:Open Resolved:
Product:iOS + SDK Product Version:11.2
Classification:Other Bug Reproducible:Always

In Swift, titleTextAttributes APIs have inconsistent types:
UINavigationBar.titleTextAttributes: [NSAttributedStringKey : Any]?
UIBarItem.titleTextAttributes(for:): [String : Any]?
UIBarItem.setTitleTextAttributes(_:for:): [NSAttributedStringKey : Any]?
UISegmentedControl.titleTextAttributes(for:): [AnyHashable : Any]?
UISegmentedControl.setTitleTextAttributes(_:for:): [AnyHashable : Any]?
UISearchBar.scopeBarButtonTitleTextAttributes(for:): [String : Any]?
UISearchBar.setScopeBarButtonTitleTextAttributes(_:for:): [String : Any]?

The worst of them is the inconsistency between UIBarItem.titleTextAttributes(for:) and UIBarItem.setTitleTextAttributes(_:for:):
UIBarItem.setTitleTextAttributes to its own titleTextAttributes due to type mismatch.

All these types should be [NSAttributedStringKey : Any]?.


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!