if (self.advertisingSwitch.on) {
// All we advertise is our service's UUID
[self.peripheralManager startAdvertising:@{ CBAdvertisementDataServiceUUIDsKey : @[[CBUUID UUIDWithString:TRANSFER_SERVICE_UUID]] }];
}
else {
[self.peripheralManager stopAdvertising];
}
我把它翻译成Swift:
if self.advertisingSwitch.on {
self.peripheralManager.startAdvertising([CBUUID(string: TRANSFERSERVICEUUID)])
} else {
self.peripheralManager.stopAdvertising()
}
它给了我错误:"无法使用类型的参数列表([CBUUID])"
调用StartAdvertising答案 0 :(得分:1)
试试这个
if self.advertisingSwitch.on {
self.peripheralManager.startAdvertising([CBAdvertisementDataServiceUUIDsKey:[TRANSFER_SERVICE_UUID]])
} else {
self.peripheralManager.stopAdvertising()
}