RVS_BTDriver_MacOS_Test_Harness_AppDelegate

@NSApplicationMain
class RVS_BTDriver_MacOS_Test_Harness_AppDelegate : NSObject, NSApplicationDelegate
extension RVS_BTDriver_MacOS_Test_Harness_AppDelegate: RVS_BTDriverDelegate

This class is the main application delegate.

It is also the “owner” of the driver instance, and acts as the delegate for the driver.

  • This is the internal holder for the driver instance. It is initialized as a singleton, the first time it’s accessed.

    Declaration

    Swift

    private var _driverInstance: RVS_BTDriver!

Internal 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: RVS_BTDriver_MacOS_Test_Harness_AppDelegate { get }

    Return Value

    the app delegate object, in its natural environment.

Internal Instance Properties

Internal Instance Computed Properties

  • This indicates that the driver is scanning for new devices. If set to true, and the driver is initialized, the driver will start scanning (unless it is already scanning). If it is set to false, and the driver is initialized and scanning, the driver will stop scanning. Otherwise, it is ignored.

    Declaration

    Swift

    @objc
    dynamic var isScanning: Bool { get set }
  • Returns true, if bluetooth is available. READ-ONLY

    Declaration

    Swift

    @objc
    dynamic var isBTAvailable: Bool { get }

Instance Methods

  • This establishes the driver instance, wiping out any old one.

    If the driver was previously scanning, it will start scanning again. This may mean that deleted devices get rediscovered.

    Declaration

    Swift

    func setUpDriver()
  • 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.

RVS_BTDriverDelegate Methods

  • Simple error reporting method.

    Declaration

    Swift

    func btDriver(_ inDriver: RVS_BTDriver, encounteredThisError inError: RVS_BTDriver.Errors)

    Parameters

    inDriver

    The RVS_BTDriver instance that encountered the error.

    encounteredThisError

    The error that was encountered.

  • Called when a new device is discovered while scanning.

    Declaration

    Swift

    func btDriver(_ inDriver: RVS_BTDriver, newDeviceAdded inDevice: RVS_BTDriver_DeviceProtocol)

    Parameters

    inDriver

    The RVS_BTDriver instance that is calling this.

    newDeviceAdded

    The new device instance.

  • Called to indicate that the driver’s status should be checked.

    It may be called frequently, and there may not be any changes. This is mereley a “make you aware of the POSSIBILITY of a change” call.

    This is optional, and is NOT guaranteed to be called in the main thread.

    Declaration

    Swift

    func btDriverStatusUpdate(_ inDriver: RVS_BTDriver)

    Parameters

    driver

    The RVS_BTDriver instance calling this.

  • Called to indicate that the driver started or stopped scanning.

    This is optional, and is NOT guaranteed to be called in the main thread.

    Declaration

    Swift

    func btDriverScanningChanged(_ driver: RVS_BTDriver, isScanning: Bool)

    Parameters

    driver

    The RVS_BTDriver instance calling this.

    isScanning

    True, if the new state is scanning is on.