5T4TiC 5T4TiC - 1 month ago 9
Objective-C Question

Phillips HUE SDK in Swift




I am very new to Swift! I do have some experience with Objective-C (although it has been around two years since i've really written anything in it). I am trying to use the Phillips HUE SDK with Swift, and am having some trouble! I am trying to re-write the following Objective-C code into Swift:


// Start search for bridges
[self.bridgeSearch startSearchWithCompletionHandler:^(NSDictionary *bridgesFound) {
//Search complete
[self showBridgesFound:bridgesFound];
}


I have had no luck looking online for a solution on this, and there is no documentation through Phillips. Has anyone had experience with this, could you please provide assistance?

Answer Source

The tricky piece is figuring out the syntax of the Swift equivalent of the NSDictionary.

self.bridgeSearch.startSearchWithCompletionHandler { (bridgesFound: [NSObject : AnyObject]!) -> Void in
    self.showBridgesFound(bridgesFound)
}