2015-05-28 3 views
0
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 как:Перевод ObjC код IOS Swift

if self.advertisingSwitch.on { 

     self.peripheralManager.startAdvertising([CBUUID(string: TRANSFERSERVICEUUID)]) 

    } else { 

     self.peripheralManager.stopAdvertising() 
    } 

Это дает мне ошибку: "не может ссылаться на StartAdvertising со списком аргументов типа ([CBUUID])"

ответ

1

попробовать это

if self.advertisingSwitch.on { 
    self.peripheralManager.startAdvertising([CBAdvertisementDataServiceUUIDsKey:[TRANSFER_SERVICE_UUID]]) 
} else { 
    self.peripheralManager.stopAdvertising() 
} 
+0

Он построен с использованием этого формата. Большое спасибо! – pmoney13

+0

рад, что я мог бы помочь! – Steve

Смежные вопросы