Я разрабатываю приложение Bluetooth. У меня есть имя доступного устройства Bluetooth в представлении таблицы. Если нажать на устройство, я хочу узнать имя UUID всех поддерживаемых служб в другом контроллере представления с представлением таблицы. Дайте мне идею.
1)Управление периферией (NSObject)
2)FirstViewController (в этом у меня есть имя устройства)
3)SecondViewController (в этом мне нужны поддерживаемые службы)
Периферийный менеджер.м
- (void)centralManager:(CBCentralManager *)central
didDiscoverPeripheral:(CBPeripheral *)peripheral
advertisementData:(NSDictionary *)advertisementData
RSSI:(NSNumber *)RSSI
{
NSLog(@"didDiscoverPeriphera.peripheral: %@ rssi: %@, UUID:%@ advertisementData:%@", peripheral,RSSI,peripheral.UUID, [advertisementData description]);
targetPeripheral = peripheral;
peripheral.delegate = self;
if (!peripheral.isConnected)
{
[centralManager connectPeripheral:peripheral options:nil];
}
}
Фирствиевконтроллер.m
- (void)peripheralManagerDidConnectPeripheral:(PeripheralManager *)peripheral
{
NSLog(@"%@",peripheral.deviceName);
NSLog(@"%@",peripheral.rssi);
[device addObject:[NSString stringWithFormat:@"%@",peripheral.deviceName]];
[self.deviceTable reloadData];
}
Таблица
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier=@"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if(cell==nil)
{
cell =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text=[device objectAtIndex:indexPath.row];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
Если вам нужна дополнительная информация, пожалуйста, спросите меня.
Пожалуйста, проверьте эту ссылку пример приложения Itunes
изображение