When I migrated to Swift 4.2 last year, Swift 4.2 migrator added a helper function in some of my controllers:
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
}
When is it safe to remove?
Presumably, some function in that file (or in a prior version of the file) calls this UIApplication
method:
func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey : Any] = [:], completionHandler completion: ((Bool) -> Void)? = nil)
Prior to iOS 12, the method had a different signature:
func open(_ url: URL, options: [String : Any] = [:], completionHandler completion: ((Bool) -> Void)? = nil)
When Xcode 10 migrated your project, it added the convertToUIApplicationOpenExternalURLOptionsKeyDictionary
function and inserted a call to that function in each call to the open(_:options:completionHandler:)
method to translate the options dictionary.
If you update each call to the open(_:options:completionHandler:)
method to use the UIApplication.OpenExternalURLOptionsKey
constants, you can remove the calls to convertToUIApplicationOpenExternalURLOptionsKeyDictionary
and remove the function entirely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With