我的代碼:斯威夫特無法將類型CBPeripheral的價值預期參數類型
func didDiscoverBLE(_ peripheral: CBPeripheral!, address: String!, rssi: Int32) {
DispatchQueue.main.async(execute: {() -> Void in
// Handle Discovery
self.arrayPeripehral.contains(where:peripheral)
return
})
self.arrayPeripehral.append(peripheral)
let title: String = "\(peripheral.name) \(address) (RSSI:\(rssi))"
self.arrayPeripheralName.append(title)
在這一行我有一個問題:
self.arrayPeripehral.contains(where:peripheral)
return
})
有沒有人的想法?
下面是我從obective複製C將迅速而就死在這個錯誤
- (void)didDiscoverBLE:(CBPeripheral *)peripheral address:(NSString *)address rssi:(int)rssi
{
dispatch_async(dispatch_get_main_queue(), ^{
// Handle Discovery
if([arrayPeripehral containsObject:peripheral])
return;
[arrayPeripehral addObject:peripheral];
NSString * title = [NSString stringWithFormat:@"%@ %@ (RSSI:%d)", peripheral.name, address, rssi];
[arrayPeripheralName addObject:title];
你可以顯示'arrayPeripehral'的聲明。 –
var arrayPeripehral = [Any]()var arrayPeripheralName = [Any]() –
我使用框架obj c和我有briddging文件,我宣佈外圍設備 var peripheral:CBPeripheral? var arrayPeripehral = [Any]() var arrayPeripheralName = [Any]() –