Mohammed Saleh Mohammed Saleh - 2 months ago 8
Swift Question

what is equivalent Swift code of this Objective-c code?

- (void) registerHotspot: (NEHotspotNetwork*) network andCommand:(NEHotspotHelperCommand*) cmd
{
if ([network.SSID isEqualToString:@"Chameleon Cafe"])
{
[network setConfidence:kNEHotspotHelperConfidenceHigh];
[network setPassword:@"chamcafe"];
NEHotspotHelperResponse *response = [cmd createResponse:kNEHotspotHelperResultSuccess];
NSLog(@"Response CMD %@", response);

[response setNetworkList:@[network]];
[response setNetwork:network];
[response deliver];
}

NEHotspotNetwork * myNetwork = [[NEHotspotNetwork alloc] init];

}

Answer
func registerHotspot(network : NEHotspotNetwork, andCommand cmd : NEHotspotHelperCommand){
        if(network.SSID == "Chameleon Cafe"){
            network.setConfidence(.High)
            network.setPassword("chamcafe")
            let response : NEHotspotHelperResponse = cmd.createResponse(.Success)
            print("Response CMD \(response)")
            response.setNetworkList([network])
            response.setNetwork(network)
            response.deliver()
        }

        let myNetwork = NEHotspotNetwork()
    }