MacOS_AppDelegate

@NSApplicationMain
class MacOS_AppDelegate : NSObject, NSApplicationDelegate
extension MacOS_AppDelegate: CGA_BlueThoth_Delegate
  • This is the unique key for the device discovery panel.

    Declaration

    Swift

    static let deviceScreenID: String
  • This is the length of our timeout, in seconds.

    Declaration

    Swift

    static let timeoutInSeconds: TimeInterval
  • This is the menu item for the main app menu. It allows us to customize the text.

    Declaration

    Swift

    @IBOutlet
    weak var appNameMenuTitle: NSMenuItem!
  • This is the menu item for the about item. It allows us to customize the text.

    Declaration

    Swift

    @IBOutlet
    weak var aboutMenuItem: NSMenuItem!
  • This is the menu item for the quit item. It allows us to customize the text.

    Declaration

    Swift

    @IBOutlet
    weak var quitMenuItem: NSMenuItem!
  • The help menu item.

    Declaration

    Swift

    @IBOutlet
    weak var helpMenuItem: NSMenuItem!
  • The “hide this app” menu item.

    Declaration

    Swift

    @IBOutlet
    weak var hideMenuItem: NSMenuItem!
  • This is the Bluetooth Central Manager instance. Everything goes through this.

    Declaration

    Swift

    var centralManager: RVS_BlueThoth?
  • This will contain our persistent prefs

    Declaration

    Swift

    var prefs: CGA_PersistentPrefs
  • This has our open windows.

    Declaration

    Swift

    var screenList: [MacOS_ControllerList_Protocol]
  • This is true, if the main window is open.

    Declaration

    Swift

    @objc
    dynamic var mainSreenOpen: Bool { get }

Application Delegate Protocol Conformance

Class Computed Properties

  • This is a quick way to get this object instance (it’s a SINGLETON), cast as the correct class.

    Declaration

    Swift

    @objc
    dynamic class var appDelegateObject: MacOS_AppDelegate { get }

    Return Value

    the app delegate object, in its natural environment.

Class Functions

  • This displays a simple alert, with an OK button.

    Declaration

    Swift

    class func displayAlert(header inHeader: String, message inMessage: String = "")

    Parameters

    header

    The header to display at the top.

    message

    A String, containing whatever messge is to be displayed below the header.

Instance Methods

  • Updates a single screen UI.

    Declaration

    Swift

    func updateScreen(_ inScreenID: String)

    Parameters

    inScreenID

    A String, with the unique ID of the screen.

  • This closes any open screens, and disconnects any connected Peripherals.

    Declaration

    Swift

    func collapseSplit()

CGA_BlueThoth_Delegate Conformance

  • Handles an error from the SDK.

    Declaration

    Swift

    func handleError(_ inError: CGA_Errors, from inCentralInstance: RVS_BlueThoth)

    Parameters

    inError

    The error that occurred.

    from

    The Central instance that experienced the error.

  • This is called to tell the instance to do whatever it needs to do to update its data. NOTE: There may be no changes, or many changes. What has changed is not specified.

    Declaration

    Swift

    func updateFrom(_ inCentralInstance: RVS_BlueThoth)

    Parameters

    inCentralInstance

    The central manager that is calling this.

  • This is called to tell the instance that a Peripheral device has been connected.

    Declaration

    Swift

    func centralManager(_ inCentralInstance: RVS_BlueThoth, didConnectThisDevice inPeripheral: CGA_Bluetooth_Peripheral)

    Parameters

    inCentralInstance

    The central manager that is calling this.

    didConnectThisDevice

    The device instance that was connected.

  • Called prior to a device being disconnected.

    Declaration

    Swift

    func centralManager(_ inCentralInstance: RVS_BlueThoth, willDisconnectThisDevice inDevice: CGA_Bluetooth_Peripheral)

    Parameters

    inCentralInstance

    The central manager that is calling this.

    willDisconnectThisDevice

    The device instance that will be disconnected.

  • This is called to tell the instance that a Peripheral device has had some change.

    Declaration

    Swift

    func centralManager(_ inCentralManager: RVS_BlueThoth, deviceInfoChanged inDevice: CGA_Bluetooth_Peripheral)

    Parameters

    inCentralManager

    The central manager that is calling this.

    deviceInfoChanged

    The device instance that was connected.

  • This is called to tell the instance that the state of the Central manager just became “powered on.”

    Declaration

    Swift

    func centralManagerPoweredOn(_ inCentralInstance: RVS_BlueThoth)

    Parameters

    inCentralInstance

    The central manager that is calling this.

  • This is called to tell the instance that a Characteristic changed its notification state.

    Declaration

    Swift

    func centralManager(_ inCentral: RVS_BlueThoth, device inDevice: CGA_Bluetooth_Peripheral, service inService: CGA_Bluetooth_Service, changedCharacteristicNotificationState inCharacteristic: CGA_Bluetooth_Characteristic)

    Parameters

    inCentral

    The central manager that is calling this.

    device

    The device instance that contained the changed Service.

    service

    The Service instance that contained the changed Characteristic.

    changedCharacteristicNotificationState

    The Characteristic that was changed.

  • This is called when a Peripheral announces a change to one of its Characteristics.

    Declaration

    Swift

    func centralManager(_ inCentral: RVS_BlueThoth, device inDevice: CGA_Bluetooth_Peripheral, service inService: CGA_Bluetooth_Service, changedCharacteristic inCharacteristic: CGA_Bluetooth_Characteristic)

    Parameters

    inCentralInstance

    The central manager that is calling this.

    device

    The Peripheral that contains the changed Characteristic.

    service

    The Service that contains the changed Characteristic.

    changedCharacteristic

    The Characteristic that has experienced the change.

  • This is called to tell the instance that a Characteristic write with response received its response.

    Declaration

    Swift

    func centralManager(_ inCentralManager: RVS_BlueThoth, device inPeripheral: CGA_Bluetooth_Peripheral, service inService: CGA_Bluetooth_Service, characteristicWriteComplete inCharacteristic: CGA_Bluetooth_Characteristic)

    Parameters

    inCentralManager

    The central manager that is calling this.

    device

    The device instance that contained the changed Service.

    service

    The Service instance that contained the changed Characteristic.

    characteristicWriteComplete

    The Characteristic that had its write completed.

  • This is called to tell the instance that a Descriptor changed its value.

    Declaration

    Swift

    public func centralManager(_ inCentral: RVS_BlueThoth, device inDevice: CGA_Bluetooth_Peripheral, service inService: CGA_Bluetooth_Service, characteristic inCharacteristic: CGA_Bluetooth_Characteristic, changedDescriptor inDescriptor: CGA_Bluetooth_Descriptor)

    Parameters

    centralManager

    The central manager that is calling this.

    device

    The device instance that contained the changed Service.

    service

    The Service instance that contained the changed Characteristic.

    characteristic

    The Characteristic that contains the Descriptor that was changed.

    changedDescriptor

    The Descriptor that was changed.