Reputation: 628
i'm trying to search for a peripheral with particular service UUID, and i enter the line of code as follow but it pop out error, did i miss out something? can someone suggest please.
centralManager.scanForPeripheralsWithServices([NSArray arrayWithObject [CBUUID UUIDWithString:@ "180A"]], options: nil)
Upvotes: 0
Views: 466
Reputation: 6885
you mixed swift's syntax with Objective-C's syntax,no wonder there is an error.
IN Objective-C:
[centralManager scanForPeripheralsWithServices:[NSArray arrayWithObject :[CBUUID UUIDWithString:@ "180A"]] options:nil];
IN swift:
centralManager.scanForPeripheralsWithServices([CBUUID(string: "180A")], options: nil)
Upvotes: 1
Reputation: 194
seems to be syntax error that what i understood from info u provided.
try this code..
let serviceUUIDs:[AnyObject] = [CBUUID(string: "180D")] centralManager.scanForPeripheralsWithServices(serviceUUIDs, options: nil)
Upvotes: 2