Ios 如何在Swift中使用centralManager?
我让我的应用程序将其手机用作中心,并在外围设备广播时执行任务。因此,我正在与之斗争Ios 如何在Swift中使用centralManager?,ios,swift,core-bluetooth,Ios,Swift,Core Bluetooth,我让我的应用程序将其手机用作中心,并在外围设备广播时执行任务。因此,我正在与之斗争 func centralManager(central: CBCentralManager!, willRestoreState dict: [NSObject : AnyObject]!) { } CoreBluetooth编程指南对于这个函数中的内容非常模糊,我看到的所有示例都是Objective-C,我不太清楚。例如: - (void)centralManager:(CBCentralManager *
func centralManager(central: CBCentralManager!, willRestoreState dict: [NSObject : AnyObject]!) {
}
CoreBluetooth编程指南对于这个函数中的内容非常模糊,我看到的所有示例都是Objective-C,我不太清楚。例如:
- (void)centralManager:(CBCentralManager *)central willRestoreState:(NSDictionary *)state {
activePeripheral = [state[CBCentralManagerRestoredStatePeripheralsKey] firstItem];
activePeripheral.delegate = self;
NSString *str = [NSString stringWithFormat: @"%@ %lu", @"Device: ", activePeripheral.UUID];
[self sendNotification:str];
}
作为一名Swift开发新手,我不确定我应该在这个函数中表达什么。有人能解释一下或者提供一个实际的例子吗?我假设我的CBCentralManager需要在某个时候被引用。我发现这个函数中不需要任何东西;它只是自动执行它,或者在我看来是这样。建议使用NSLog或println()