MacOS_PeripheralViewController
class MacOS_PeripheralViewController : RVS_BlueThoth_MacOS_Test_Harness_Base_SplitView_ViewController
extension MacOS_PeripheralViewController: MacOS_ControllerList_Protocol
extension MacOS_PeripheralViewController: NSTableViewDelegate, NSTableViewDataSource
This controls the main screen for a Peripheral, once it has been selected in the Discovery screen. It appears in the first screen to the right of the Discovery Screen.
-
This is the storyboard ID that we use to create an instance of this view.
Declaration
Swift
static let storyboardID: String
-
This is the initial width of the new section.
Declaration
Swift
static let minimumThickness: CGFloat
-
If a Characteristic was selected in the table, this is a semaphore for that.
Declaration
Swift
private var _selectedCharacteristic: CGA_Bluetooth_Characteristic?
-
This will map the discovered Services and Characteristics for display in the table. The key is the ID of the Service. The value is all the rows (Characteristic IDs) it will display.
Declaration
Swift
private var _tableMap: [String : [String]]
-
This is the Peripheral instance associated with this screen.
Declaration
Swift
var peripheralInstance: RVS_BlueThoth.DiscoveryData? { get set }
-
This is the outer container of the Services tableView.
Declaration
Swift
@IBOutlet weak var serviceTableContainerView: NSScrollView!
-
This is the Services tableView.
Declaration
Swift
@IBOutlet weak var serviceTableView: NSTableView!
-
This is the spinner that is displayed while the device is being connected.
Declaration
Swift
@IBOutlet weak var loadingSpinner: NSProgressIndicator!
-
Called when the disconnect button is hit, or we want to disconnect the device.
Declaration
Swift
@IBAction func disconnectThisPeripheral(_: Any! = nil)
-
This is a complete count of all advertisement data rows, and headers.
Declaration
Swift
private var _completeTableMapRowCount: Int { get }
-
This just helps us to keep the table in a predictable order.
Declaration
Swift
private var _sortedServices: [String] { get }
-
This builds a “map” of the device data, so we can build a table from it.
Declaration
Swift
private func _buildTableMap()
-
This returns the row string, along with whether or not it is a header, for the indexed row.
Declaration
Swift
private func _getIndexedTableMapRow(_ inIndex: Int) -> (value: String, isHeader: Bool)
Parameters
inIndex
The 0-based row index.
Return Value
a tuple, containing the string value, and a boolean flag, indicating whether or not it is a header.
-
This shows and starts the loading spinner.
Declaration
Swift
func startLoadingAnimation()
-
This stops and hides the loading spinner.
Declaration
Swift
func stopLoadingAnimation()
-
Called when the view hierachy has loaded.
Declaration
Swift
override func viewDidLoad()
-
Called just before the screen appears. We use this to register with the app delegate.
Declaration
Swift
override func viewWillAppear()
-
Called just before the screen disappears. We use this to un-register with the app delegate.
Declaration
Swift
override func viewWillDisappear()
-
Sets up the various accessibility labels.
Declaration
Swift
override func setUpAccessibility()
-
This is a String key that uniquely identifies this screen.
Declaration
Swift
var key: String { get }
-
This forces the UI elements to be updated.
Declaration
Swift
func updateUI()
-
Called to supply the number of rows in the table.
Declaration
Swift
func numberOfRows(in inTableView: NSTableView) -> Int
Parameters
inTableView
The table instance.
Return Value
A 1-based Int, with 0 being no rows.
-
This is called to supply the string display for one row that corresponds to a device.
Declaration
Swift
func tableView(_ inTableView: NSTableView, objectValueFor inTableColumn: NSTableColumn?, row inRow: Int) -> Any?
Parameters
inTableView
The table instance.
objectValueFor
Container object for the column that holds the row.
row
0-based Int, with the index of the row, within the column.
Return Value
A String, with the device name.
-
Called to indicate whether or not the row is a group header.
Declaration
Swift
func tableView(_ inTableView: NSTableView, isGroupRow inRow: Int) -> Bool
Parameters
inTableView
The table instance.
isGroupRow
The 0-based Int index of the row.
Return Value
True, if this is a group header row.
-
This is called when a row is selected. We match the device to the row, set that in the semaphore, and approve the selection.
Declaration
Swift
func tableView(_ inTableView: NSTableView, shouldSelectRow inRow: Int) -> Bool
Parameters
inTableView
The table instance.
shouldSelectRow
0-based Int, with the index of the row, within the column.
Return Value
False (always).
-
Called after the selection was set up and approved.
We open a modal window, with the device info.
Declaration
Swift
func tableViewSelectionDidChange(_: Notification)