这里发生了一些非常奇怪的事情:
1 - (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {
2 if (error) {
3 NSLog(@"Error discovering services: %@", [error localizedDescription]);
4 return;
5 }
6 for (CBService *service in peripheral.services) {
7 NSLog(@"found service");
8 if ([service.UUID isEqual:[CBUUID UUIDWithString:@"6D59"]]) { // SwitchaBLE UUID
9 [peripheral discoverCharacteristics:@[[CBUUID UUIDWithString:@"6D5A"], [CBUUID UUIDWithString:@"6D5B"], [CBUUID UUIDWithString:@"6D5C"]] forService:service];
10 }
11 }
12 }
peripheral.services
没有对象。print service
告诉我:error: use of undeclared identifier 'service'
。刚刚发生了什么事?