pmoney13
pmoney13

Reputation: 1105

Translating ObjC code to iOS Swift

 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];
    }

I have it translated in Swift as:

if self.advertisingSwitch.on {

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

    } else {

        self.peripheralManager.stopAdvertising()
    }

It is giving me the error: "cannot invoke StartAdvertising with argument list of type ([CBUUID])"

Upvotes: 0

Views: 164

Answers (1)

Steve
Steve

Reputation: 1421

try this

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

Upvotes: 1

Related Questions