IOS 5.0.1 iPhone 4S で Bluetooth を使用してデバイス検出を実装しようとしています。プライベート フレームワーク BluetoothManager を使用しています。
私のコードは次のとおりです。
- (IBAction)searchForDevices:(id)sender
{
[self.indicator setHidden:NO];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(bluetoothAvailabilityChanged:) name:@"BluetoothAvailabilityChangedNotification" object:nil];
btCont = [BluetoothManager sharedInstance];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceDiscovered:) name:@"BluetoothDeviceDiscoveredNotification" object:nil];
}
- (void)bluetoothAvailabilityChanged:(NSNotification *)notification
{
self.label.text = @"Availability changed!";
[btCont setDeviceScanningEnabled:YES];
}
- (void)deviceDiscovered:(BluetoothDevice *)device
{
[self.indicator setHidden:YES];
self.label.text = device.address;
Bluetooth ヘッドセットが検出されました。deviceDiscovered コールバック関数が呼び出されますが、device.address には Bluetooth デバイスの MAC アドレスが含まれていません。アプリがクラッシュしています。また、device.name は、検出されたデバイスの名前ではなく、通知の名前 (BluetoothDeviceDiscoveredNotification) を返します。
この方法で Bluetooth ヘッドセットの MAC アドレスを取得するにはどうすればよいですか?