Ios UITextView被阻止,因为外围设备:didUpdateValueForCharacteristic:调用速度非常快

Ios UITextView被阻止,因为外围设备:didUpdateValueForCharacteristic:调用速度非常快,ios,core-bluetooth,cbcentralmanager,cbperipheral,cbperipheralmanager,Ios,Core Bluetooth,Cbcentralmanager,Cbperipheral,Cbperipheralmanager,我试图通过附加来自外围设备的数据来在UITextView中显示数据:didUpdateValueForCharacteristic:错误:。在这种情况下,外围设备:didUpdateValueForCharacteristic:error:被频繁调用,因此UITextView self.responseTextView无法打印任何数据或阻塞UI - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristi

我试图通过附加来自外围设备的数据来在UITextView中显示数据:didUpdateValueForCharacteristic:错误:。在这种情况下,外围设备:didUpdateValueForCharacteristic:error:被频繁调用,因此UITextView self.responseTextView无法打印任何数据或阻塞UI

- (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);
    }
}

什么是价值观?值是否更改?是数字吗?如果是文本,您可能只会在文本更改时更新,如果是数字,您可以根据情况等待5/10的值并进行平均。您可以计算它被调用的次数,并且仅在计数足够高时更新,或者可能使用时间戳并且仅在经过特定时间时更新。或者混合所有这些想法…你确定didUpdateValueForCharacteristic:在主线程上被调用了吗?UI更新在后台线程中无法正常工作。