Я не могу установить основной ярлык ячейки на имя соответствующего периферийного устройства.
помогите мне найти решение !!
описание изображения здесь
var activeCentralManager: CBCentralManager?
var peripheralDevice: CBPeripheral?
var devices: Dictionary<String, CBPeripheral> = [:]
var deviceName: String?
var devicesRSSI = [NSNumber]()
var devicesServices: CBService!
var deviceCharacteristics: CBCharacteristic!
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return devices.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// Let's get a cell.
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
// Turn the device dictionary into an array.
let discoveredPeripheralArray = devices as? [String : CBPeripheral]
//println(discoveredPeripheralArray.count)
// Set the main label of the cell to the name of the corresponding peripheral.
if let cell = cell{
if let name = discoveredPeripheralArray?[indexPath.row].name{
if let textLabelText = cell.textLabel{
textLabelText.text = name
}
if let detailTextLabel = cell.detailTextLabel{
detailTextLabel.text = devicesRSSI[indexPath.row].stringValue
}
}
}
return cell!
}