Documentation Archive Developer
Search

WatchKit Changes for Swift

WatchKit

Declaration
From
class WKInterfaceController : NSObject {
    init()
    func awake(withContext context: Any?)
    var contentFrame: CGRect { get }
    var crownSequencer: WKCrownSequencer { get }
    func willActivate()
    func didDeactivate()
    func didAppear()
    func willDisappear()
    func pickerDidFocus(_ picker: WKInterfacePicker)
    func pickerDidResignFocus(_ picker: WKInterfacePicker)
    func pickerDidSettle(_ picker: WKInterfacePicker)
    func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int)
    func handleAction(withIdentifier identifier: String?, for notification: UNNotification)
    func handleUserActivity(_ userInfo: [AnyHashable : Any]?)
    func setTitle(_ title: String?)
    func pushController(withName name: String, context context: Any?)
    func pop()
    func popToRootController()
    class func reloadRootControllers(withNames names: [String], contexts contexts: [Any]?)
    func becomeCurrentPage()
    func presentController(withName name: String, context context: Any?)
    func presentController(withNames names: [String], contexts contexts: [Any]?)
    func dismiss()
    func presentTextInputController(withSuggestions suggestions: [String]?, allowedInputMode inputMode: WKTextInputMode, completion completion: @escaping ([Any]?) -> Swift.Void)
    func presentTextInputControllerWithSuggestions(forLanguage suggestionsHandler: (@escaping (String) -> [Any]?)?, allowedInputMode inputMode: WKTextInputMode, completion completion: @escaping ([Any]?) -> Swift.Void)
    func dismissTextInputController()
    func presentMediaPlayerController(with URL: URL, options options: [AnyHashable : Any]? = nil, completion completion: @escaping (Bool, TimeInterval, Error?) -> Swift.Void)
    func dismissMediaPlayerController()
    func presentAudioRecorderController(withOutputURL URL: URL, preset preset: WKAudioRecorderPreset, options options: [AnyHashable : Any]? = nil, completion completion: @escaping (Bool, Error?) -> Swift.Void)
    func dismissAudioRecorderController()
    func contextForSegue(withIdentifier segueIdentifier: String) -> Any?
    func contextsForSegue(withIdentifier segueIdentifier: String) -> [Any]?
    func contextForSegue(withIdentifier segueIdentifier: String, in table: WKInterfaceTable, rowIndex rowIndex: Int) -> Any?
    func contextsForSegue(withIdentifier segueIdentifier: String, in table: WKInterfaceTable, rowIndex rowIndex: Int) -> [Any]?
    func animate(withDuration duration: TimeInterval, animations animations: @escaping () -> Swift.Void)
    func presentAlert(withTitle title: String?, message message: String?, preferredStyle preferredStyle: WKAlertControllerStyle, actions actions: [WKAlertAction])
    func presentAddPassesController(withPasses passes: [PKPass], completion completion: @escaping () -> Swift.Void)
    func dismissAddPassesController()
    func addMenuItem(with image: UIImage, title title: String, action action: Selector)
    func addMenuItem(withImageNamed imageName: String, title title: String, action action: Selector)
    func addMenuItem(with itemIcon: WKMenuItemIcon, title title: String, action action: Selector)
    func clearAllMenuItems()
    func updateUserActivity(_ type: String, userInfo userInfo: [AnyHashable : Any]? = nil, webpageURL webpageURL: URL?)
    func invalidateUserActivity()
    class func openParentApplication(_ userInfo: [AnyHashable : Any], reply reply: (@escaping ([AnyHashable : Any], Error?) -> Swift.Void)? = nil) -> Bool
    func beginGlanceUpdates()
    func endGlanceUpdates()
    func handleAction(withIdentifier identifier: String?, forRemoteNotification remoteNotification: [AnyHashable : Any])
    func handleAction(withIdentifier identifier: String?, for localNotification: UILocalNotification)
    @nonobjc final class func reloadRootControllers(_ namesAndContexts: [(name: String, context: AnyObject)])
    class func reloadRootControllers(withNamesAndContexts namesAndContexts: [(name: String, context: AnyObject)])
    @nonobjc final func presentController(_ namesAndContexts: [(name: String, context: AnyObject)])
    func presentController(withNamesAndContexts namesAndContexts: [(name: String, context: AnyObject)])
    func awakeFromNib()
    func prepareForInterfaceBuilder()
    func accessibilityActivate() -> Bool
    func accessibilityIncrement()
    func accessibilityDecrement()
    func accessibilityScroll(_ direction: UIAccessibilityScrollDirection) -> Bool
    func accessibilityPerformEscape() -> Bool
    func accessibilityPerformMagicTap() -> Bool
    var accessibilityCustomActions: [UIAccessibilityCustomAction]?
    func accessibilityElementDidBecomeFocused()
    func accessibilityElementDidLoseFocus()
    func accessibilityElementIsFocused() -> Bool
    func accessibilityAssistiveTechnologyFocusedIdentifiers() -> Set<String>?
    func accessibilityElementCount() -> Int
    func accessibilityElement(at index: Int) -> Any?
    func index(ofAccessibilityElement element: Any) -> Int
    var accessibilityElements: [Any]?
    var isAccessibilityElement: Bool
    var accessibilityLabel: String?
    var accessibilityHint: String?
    var accessibilityValue: String?
    var accessibilityTraits: UIAccessibilityTraits
    var accessibilityFrame: CGRect
    @NSCopying var accessibilityPath: UIBezierPath?
    var accessibilityActivationPoint: CGPoint
    var accessibilityLanguage: String?
    var accessibilityElementsHidden: Bool
    var accessibilityViewIsModal: Bool
    var shouldGroupAccessibilityChildren: Bool
    var accessibilityNavigationStyle: UIAccessibilityNavigationStyle
    var accessibilityHeaderElements: [Any]?
    var accessibilityCustomRotors: [UIAccessibilityCustomRotor]?
    func performSelector(onMainThread aSelector: Selector, with arg: Any?, waitUntilDone wait: Bool, modes array: [String]?)
    func performSelector(onMainThread aSelector: Selector, with arg: Any?, waitUntilDone wait: Bool)
    func perform(_ aSelector: Selector, on thr: Thread, with arg: Any?, waitUntilDone wait: Bool, modes array: [String]?)
    func perform(_ aSelector: Selector, on thr: Thread, with arg: Any?, waitUntilDone wait: Bool)
    func performSelector(inBackground aSelector: Selector, with arg: Any?)
    class func classForKeyedUnarchiver() -> AnyClass
    var classForKeyedArchiver: AnyClass? { get }
    func replacementObject(for archiver: NSKeyedArchiver) -> Any?
    class func classFallbacksForKeyedArchiver() -> [String]
    class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String>
    class func automaticallyNotifiesObservers(forKey key: String) -> Bool
    var observationInfo: UnsafeMutableRawPointer?
    func willChangeValue(forKey key: String)
    func didChangeValue(forKey key: String)
    func willChange(_ changeKind: NSKeyValueChange, valuesAt indexes: IndexSet, forKey key: String)
    func didChange(_ changeKind: NSKeyValueChange, valuesAt indexes: IndexSet, forKey key: String)
    func willChangeValue(forKey key: String, withSetMutation mutationKind: NSKeyValueSetMutationKind, using objects: Set<AnyHashable>)
    func didChangeValue(forKey key: String, withSetMutation mutationKind: NSKeyValueSetMutationKind, using objects: Set<AnyHashable>)
    func addObserver(_ observer: NSObject, forKeyPath keyPath: String, options options: NSKeyValueObservingOptions = [], context context: UnsafeMutableRawPointer?)
    func removeObserver(_ observer: NSObject, forKeyPath keyPath: String, context context: UnsafeMutableRawPointer?)
    func removeObserver(_ observer: NSObject, forKeyPath keyPath: String)
    func observeValue(forKeyPath keyPath: String?, of object: Any?, change change: [NSKeyValueChangeKey : Any]?, context context: UnsafeMutableRawPointer?)
    class var accessInstanceVariablesDirectly: Bool { get }
    func value(forKey key: String) -> Any?
    func setValue(_ value: Any?, forKey key: String)
    func validateValue(_ ioValue: AutoreleasingUnsafeMutablePointer<AnyObject?>, forKey inKey: String) throws
    func mutableArrayValue(forKey key: String) -> NSMutableArray
    func mutableOrderedSetValue(forKey key: String) -> NSMutableOrderedSet
    func mutableSetValue(forKey key: String) -> NSMutableSet
    func value(forKeyPath keyPath: String) -> Any?
    func setValue(_ value: Any?, forKeyPath keyPath: String)
    func validateValue(_ ioValue: AutoreleasingUnsafeMutablePointer<AnyObject?>, forKeyPath inKeyPath: String) throws
    func mutableArrayValue(forKeyPath keyPath: String) -> NSMutableArray
    func mutableOrderedSetValue(forKeyPath keyPath: String) -> NSMutableOrderedSet
    func mutableSetValue(forKeyPath keyPath: String) -> NSMutableSet
    func value(forUndefinedKey key: String) -> Any?
    func setValue(_ value: Any?, forUndefinedKey key: String)
    func setNilValueForKey(_ key: String)
    func dictionaryWithValues(forKeys keys: [String]) -> [String : Any]
    func setValuesForKeys(_ keyedValues: [String : Any])
    func fileManager(_ fm: FileManager, shouldProceedAfterError errorInfo: [AnyHashable : Any]) -> Bool
    func fileManager(_ fm: FileManager, willProcessPath path: String)
    func perform(_ aSelector: Selector, with anArgument: Any?, afterDelay delay: TimeInterval, inModes modes: [RunLoopMode])
    func perform(_ aSelector: Selector, with anArgument: Any?, afterDelay delay: TimeInterval)
    class func cancelPreviousPerformRequests(withTarget aTarget: Any, selector aSelector: Selector, object anArgument: Any?)
    class func cancelPreviousPerformRequests(withTarget aTarget: Any)
    func attemptRecovery(fromError error: Error, optionIndex recoveryOptionIndex: Int, delegate delegate: Any?, didRecoverSelector didRecoverSelector: Selector?, contextInfo contextInfo: UnsafeMutableRawPointer?)
    func attemptRecovery(fromError error: Error, optionIndex recoveryOptionIndex: Int) -> Bool
    var autoContentAccessingProxy: Any { get }
    class func version() -> Int
    class func setVersion(_ aVersion: Int)
    var classForCoder: AnyClass { get }
    func awakeAfter(using aDecoder: NSCoder) -> Any?
    func provideImageData(_ data: UnsafeMutableRawPointer, bytesPerRow rowbytes: Int, origin x: Int, _ y: Int, size width: Int, _ height: Int, userInfo info: Any?)
}
extension WKInterfaceController : CVarArg {
}
extension WKInterfaceController : Equatable, Hashable {
    var hashValue: Int { get }
}
extension WKInterfaceController {
    @nonobjc final class func reloadRootControllers(_ namesAndContexts: [(name: String, context: AnyObject)])
    class func reloadRootControllers(withNamesAndContexts namesAndContexts: [(name: String, context: AnyObject)])
    @nonobjc final func presentController(_ namesAndContexts: [(name: String, context: AnyObject)])
    func presentController(withNamesAndContexts namesAndContexts: [(name: String, context: AnyObject)])
}
To
class WKInterfaceController : NSObject {
    init()
    func awake(withContext context: Any?)
    var contentFrame: CGRect { get }
    var crownSequencer: WKCrownSequencer { get }
    func willActivate()
    func didDeactivate()
    func didAppear()
    func willDisappear()
    func pickerDidFocus(_ picker: WKInterfacePicker)
    func pickerDidResignFocus(_ picker: WKInterfacePicker)
    func pickerDidSettle(_ picker: WKInterfacePicker)
    func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int)
    func handleAction(withIdentifier identifier: String?, for notification: UNNotification)
    func handleUserActivity(_ userInfo: [AnyHashable : Any]?)
    func setTitle(_ title: String?)
    func pushController(withName name: String, context context: Any?)
    func pop()
    func popToRootController()
    class func reloadRootControllers(withNames names: [String], contexts contexts: [Any]?)
    func becomeCurrentPage()
    func presentController(withName name: String, context context: Any?)
    func presentController(withNames names: [String], contexts contexts: [Any]?)
    func dismiss()
    func presentTextInputController(withSuggestions suggestions: [String]?, allowedInputMode inputMode: WKTextInputMode, completion completion: @escaping ([Any]?) -> Swift.Void)
    func presentTextInputControllerWithSuggestions(forLanguage suggestionsHandler: ((String) -> [Any]?)?, allowedInputMode inputMode: WKTextInputMode, completion completion: @escaping ([Any]?) -> Swift.Void)
    func dismissTextInputController()
    func presentMediaPlayerController(with URL: URL, options options: [AnyHashable : Any]? = nil, completion completion: @escaping (Bool, TimeInterval, Error?) -> Swift.Void)
    func dismissMediaPlayerController()
    func presentAudioRecorderController(withOutputURL URL: URL, preset preset: WKAudioRecorderPreset, options options: [AnyHashable : Any]? = nil, completion completion: @escaping (Bool, Error?) -> Swift.Void)
    func dismissAudioRecorderController()
    func contextForSegue(withIdentifier segueIdentifier: String) -> Any?
    func contextsForSegue(withIdentifier segueIdentifier: String) -> [Any]?
    func contextForSegue(withIdentifier segueIdentifier: String, in table: WKInterfaceTable, rowIndex rowIndex: Int) -> Any?
    func contextsForSegue(withIdentifier segueIdentifier: String, in table: WKInterfaceTable, rowIndex rowIndex: Int) -> [Any]?
    func animate(withDuration duration: TimeInterval, animations animations: @escaping () -> Swift.Void)
    func presentAlert(withTitle title: String?, message message: String?, preferredStyle preferredStyle: WKAlertControllerStyle, actions actions: [WKAlertAction])
    func presentAddPassesController(withPasses passes: [PKPass], completion completion: @escaping () -> Swift.Void)
    func dismissAddPassesController()
    func addMenuItem(with image: UIImage, title title: String, action action: Selector)
    func addMenuItem(withImageNamed imageName: String, title title: String, action action: Selector)
    func addMenuItem(with itemIcon: WKMenuItemIcon, title title: String, action action: Selector)
    func clearAllMenuItems()
    func updateUserActivity(_ type: String, userInfo userInfo: [AnyHashable : Any]? = nil, webpageURL webpageURL: URL?)
    func invalidateUserActivity()
    class func openParentApplication(_ userInfo: [AnyHashable : Any], reply reply: (([AnyHashable : Any], Error?) -> Swift.Void)? = nil) -> Bool
    func beginGlanceUpdates()
    func endGlanceUpdates()
    func handleAction(withIdentifier identifier: String?, forRemoteNotification remoteNotification: [AnyHashable : Any])
    func handleAction(withIdentifier identifier: String?, for localNotification: UILocalNotification)
    @nonobjc final class func reloadRootControllers(_ namesAndContexts: [(name: String, context: AnyObject)])
    class func reloadRootControllers(withNamesAndContexts namesAndContexts: [(name: String, context: AnyObject)])
    @nonobjc final func presentController(_ namesAndContexts: [(name: String, context: AnyObject)])
    func presentController(withNamesAndContexts namesAndContexts: [(name: String, context: AnyObject)])
    func awakeFromNib()
    func prepareForInterfaceBuilder()
    func accessibilityActivate() -> Bool
    func accessibilityIncrement()
    func accessibilityDecrement()
    func accessibilityScroll(_ direction: UIAccessibilityScrollDirection) -> Bool
    func accessibilityPerformEscape() -> Bool
    func accessibilityPerformMagicTap() -> Bool
    var accessibilityCustomActions: [UIAccessibilityCustomAction]?
    func accessibilityElementDidBecomeFocused()
    func accessibilityElementDidLoseFocus()
    func accessibilityElementIsFocused() -> Bool
    func accessibilityAssistiveTechnologyFocusedIdentifiers() -> Set<String>?
    func accessibilityElementCount() -> Int
    func accessibilityElement(at index: Int) -> Any?
    func index(ofAccessibilityElement element: Any) -> Int
    var accessibilityElements: [Any]?
    var isAccessibilityElement: Bool
    var accessibilityLabel: String?
    var accessibilityHint: String?
    var accessibilityValue: String?
    var accessibilityTraits: UIAccessibilityTraits
    var accessibilityFrame: CGRect
    @NSCopying var accessibilityPath: UIBezierPath?
    var accessibilityActivationPoint: CGPoint
    var accessibilityLanguage: String?
    var accessibilityElementsHidden: Bool
    var accessibilityViewIsModal: Bool
    var shouldGroupAccessibilityChildren: Bool
    var accessibilityNavigationStyle: UIAccessibilityNavigationStyle
    var accessibilityHeaderElements: [Any]?
    var accessibilityCustomRotors: [UIAccessibilityCustomRotor]?
    func performSelector(onMainThread aSelector: Selector, with arg: Any?, waitUntilDone wait: Bool, modes array: [String]?)
    func performSelector(onMainThread aSelector: Selector, with arg: Any?, waitUntilDone wait: Bool)
    func perform(_ aSelector: Selector, on thr: Thread, with arg: Any?, waitUntilDone wait: Bool, modes array: [String]?)
    func perform(_ aSelector: Selector, on thr: Thread, with arg: Any?, waitUntilDone wait: Bool)
    func performSelector(inBackground aSelector: Selector, with arg: Any?)
    class func classForKeyedUnarchiver() -> AnyClass
    var classForKeyedArchiver: AnyClass? { get }
    func replacementObject(for archiver: NSKeyedArchiver) -> Any?
    class func classFallbacksForKeyedArchiver() -> [String]
    class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String>
    class func automaticallyNotifiesObservers(forKey key: String) -> Bool
    var observationInfo: UnsafeMutableRawPointer?
    func willChangeValue(forKey key: String)
    func didChangeValue(forKey key: String)
    func willChange(_ changeKind: NSKeyValueChange, valuesAt indexes: IndexSet, forKey key: String)
    func didChange(_ changeKind: NSKeyValueChange, valuesAt indexes: IndexSet, forKey key: String)
    func willChangeValue(forKey key: String, withSetMutation mutationKind: NSKeyValueSetMutationKind, using objects: Set<AnyHashable>)
    func didChangeValue(forKey key: String, withSetMutation mutationKind: NSKeyValueSetMutationKind, using objects: Set<AnyHashable>)
    func addObserver(_ observer: NSObject, forKeyPath keyPath: String, options options: NSKeyValueObservingOptions = [], context context: UnsafeMutableRawPointer?)
    func removeObserver(_ observer: NSObject, forKeyPath keyPath: String, context context: UnsafeMutableRawPointer?)
    func removeObserver(_ observer: NSObject, forKeyPath keyPath: String)
    func observeValue(forKeyPath keyPath: String?, of object: Any?, change change: [NSKeyValueChangeKey : Any]?, context context: UnsafeMutableRawPointer?)
    class var accessInstanceVariablesDirectly: Bool { get }
    func value(forKey key: String) -> Any?
    func setValue(_ value: Any?, forKey key: String)
    func validateValue(_ ioValue: AutoreleasingUnsafeMutablePointer<AnyObject?>, forKey inKey: String) throws
    func mutableArrayValue(forKey key: String) -> NSMutableArray
    func mutableOrderedSetValue(forKey key: String) -> NSMutableOrderedSet
    func mutableSetValue(forKey key: String) -> NSMutableSet
    func value(forKeyPath keyPath: String) -> Any?
    func setValue(_ value: Any?, forKeyPath keyPath: String)
    func validateValue(_ ioValue: AutoreleasingUnsafeMutablePointer<AnyObject?>, forKeyPath inKeyPath: String) throws
    func mutableArrayValue(forKeyPath keyPath: String) -> NSMutableArray
    func mutableOrderedSetValue(forKeyPath keyPath: String) -> NSMutableOrderedSet
    func mutableSetValue(forKeyPath keyPath: String) -> NSMutableSet
    func value(forUndefinedKey key: String) -> Any?
    func setValue(_ value: Any?, forUndefinedKey key: String)
    func setNilValueForKey(_ key: String)
    func dictionaryWithValues(forKeys keys: [String]) -> [String : Any]
    func setValuesForKeys(_ keyedValues: [String : Any])
    func fileManager(_ fm: FileManager, shouldProceedAfterError errorInfo: [AnyHashable : Any]) -> Bool
    func fileManager(_ fm: FileManager, willProcessPath path: String)
    func perform(_ aSelector: Selector, with anArgument: Any?, afterDelay delay: TimeInterval, inModes modes: [RunLoopMode])
    func perform(_ aSelector: Selector, with anArgument: Any?, afterDelay delay: TimeInterval)
    class func cancelPreviousPerformRequests(withTarget aTarget: Any, selector aSelector: Selector, object anArgument: Any?)
    class func cancelPreviousPerformRequests(withTarget aTarget: Any)
    func attemptRecovery(fromError error: Error, optionIndex recoveryOptionIndex: Int, delegate delegate: Any?, didRecoverSelector didRecoverSelector: Selector?, contextInfo contextInfo: UnsafeMutableRawPointer?)
    func attemptRecovery(fromError error: Error, optionIndex recoveryOptionIndex: Int) -> Bool
    var autoContentAccessingProxy: Any { get }
    class func version() -> Int
    class func setVersion(_ aVersion: Int)
    var classForCoder: AnyClass { get }
    func awakeAfter(using aDecoder: NSCoder) -> Any?
    func provideImageData(_ data: UnsafeMutableRawPointer, bytesPerRow rowbytes: Int, origin x: Int, _ y: Int, size width: Int, _ height: Int, userInfo info: Any?)
}
extension WKInterfaceController : CVarArg {
}
extension WKInterfaceController : Equatable, Hashable {
    var hashValue: Int { get }
}
extension WKInterfaceController {
    @nonobjc final class func reloadRootControllers(_ namesAndContexts: [(name: String, context: AnyObject)])
    class func reloadRootControllers(withNamesAndContexts namesAndContexts: [(name: String, context: AnyObject)])
    @nonobjc final func presentController(_ namesAndContexts: [(name: String, context: AnyObject)])
    func presentController(withNamesAndContexts namesAndContexts: [(name: String, context: AnyObject)])
}

Declaration
From
class func openParentApplication(_ userInfo: [AnyHashable : Any], reply reply: (@escaping ([AnyHashable : Any], Error?) -> Swift.Void)? = nil) -> Bool
To
class func openParentApplication(_ userInfo: [AnyHashable : Any], reply reply: (([AnyHashable : Any], Error?) -> Swift.Void)? = nil) -> Bool

Declaration
From
func presentTextInputControllerWithSuggestions(forLanguage suggestionsHandler: (@escaping (String) -> [Any]?)?, allowedInputMode inputMode: WKTextInputMode, completion completion: @escaping ([Any]?) -> Swift.Void)
To
func presentTextInputControllerWithSuggestions(forLanguage suggestionsHandler: ((String) -> [Any]?)?, allowedInputMode inputMode: WKTextInputMode, completion completion: @escaping ([Any]?) -> Swift.Void)