UIApplication

class UIApplication : UIResponder

Extension on UIApplication to make it safe for use in iOS App extensions. For more details, see: APIs Unavailable to App Extensions.

  • Extension safe alternate to shared Returns a valid UIApplication instance for App and nil for app extensions.

    Declaration

    Swift

    public static var sharedOrNil: UIApplication? { get }
  • Extension safe alternate to open(_ url:, options: [UIApplication.OpenExternalURLOptionsKey : Any] = [:], completionHandler completion: ((Bool) -> Void)? = nil)

    Declaration

    Swift

    public func appExtensionSafeOpen(_ url: URL,
                                     options: [UIApplication.OpenExternalURLOptionsKey: Any] = [:],
                                     completion: ((Bool) -> Void)? = nil)

    Parameters

    url

    The resource identified by this URL may be local to the current app or it may be one that must be provided by a different app.

    options

    A dictionary of options to use when opening the URL.

    completion

    The block to execute with the results. Provide a value for this parameter if you want to be informed of the success or failure of opening the URL.