1

我无法didReadRSSI回电我的外围设备!

我正在iPad mini 上开发 - iOS 8.1.2

我将外围设备设置为一个NSMutable数组,我可以从该数组调用连接、断开连接等,因此附加到该数组的外围对象是有效的。

我的代码如下,有什么问题?为什么didReadRSSI我的外围设备没有收到回调??

- (void)updateConnectedRSSITimerFunc {
    for(TheCustomPeripheral *arrayItem in self.peripherals) {
      if(arrayItem.connected) {
          //This is called every 4 seconds from an NSTimer succesfully
          [arrayItem.peripheral readRSSI];
          NSLog(@"RSSI request");
      }
    }
}

-(void) peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(NSError *)error {
//This never get's called!!!!!
   NSLog(@"RSSI returned %@", [RSSI stringValue]);
}
4

1 回答 1

2

解决了!!!在计时器中我添加了这个......我对iOS还是新手,所以我错过了委托位来获取回调......

            arrayItem.peripheral.delegate = self;

作为补充问题,为什么我会收到此警告?我忽略了它,因为应用程序运行良好。

从不兼容的类型'xxxListTableViewController *const __strong'分配给'id'

答:我的班级必须是 CBPeripheralDelegate,例如 @interface myInterface ,CBPeripheralDelegate>

于 2014-12-11T00:53:50.373 回答