Le code que j'ai:Swift ne peut pas convertir la valeur de type CBPeripheral type d'argument attendu
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)
j'ai dans cette ligne un problème:
self.arrayPeripehral.contains(where:peripheral)
return
})
Quelqu'un at-il une idée?
Voici le code que je copiais du obective c au rapide et suis resté bloqué sur cette erreur
- (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];
Pouvez-vous afficher la déclaration de 'arrayPeripehral'. –
var arrayPeripehral = [Tout]() var arrayPeripheralName = [Tout]() –
Je suis l'utilisation du cadre obj c et j'ai un fichier de bridging et je déclare périphérique var périphérique: CBPeripheral? var arrayPeripehral = [Tout]() var arrayPeripheralName = [Tout]() –