1 つのビューで浮動小数点数である Bluetooth ファイル デバイス (batteryLevel) のバッテリー レベルを取得しています。それを別のビューに渡してテキストフィールドに表示したい。
ビュー 1 のコード
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:
(CBCharacteristic *)characteristic error:(NSError *)error
{[self.testPeripheral readValueForCharacteristic:mycharacteristic];
char batlevel;
[characteristic.value getBytes:&batlevel length:1];
self.batteryLevel = (float)batlevel;
NSLog(@"level;%f",batteryLevel);}
これにより、80.00000 のような値が得られます
これを別のビューに入れて表示したい。
配置したview2.hファイルで試しました
view1 *t
その後
- (void) batteryIndicatorTimer:(NSTimer *)timer {
TIBLEUIBatteryBar.progress = t.batteryLevel / 100;
[t readBattery:[t testPeripheral]]; // Read battery value of keyfob again
NSLog(@"t.batterylevel:%f",t.batteryLevel);
}
しかし、t.batteryLevelの値が得られません
私は何を間違っていますか、どうすればこれを行うことができますか?