我试图通过附加来自peripheral:didUpdateValueForCharacteristic:error:
的数据来在UITextView中显示数据。在这种情况下,peripheral:didUpdateValueForCharacteristic:error:
被频繁调用,因为UITextView
(self.responseTextView
)无法打印任何数据或阻止用户界面。
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:UNKNOWN3_CHARACTERISTICS]])
{
NSData *data = characteristic.value;
NSString *stringFromData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
self.responseTextView.text = [self.responseTextView.text stringByAppendingString:stringFromData];
NSLog(@"%@",stringFromData);
}
}