Swift Connect WiFi

let configuration = NEHotspotConfiguration.init(ssid: "SSIDname", passphrase: "Password", isWEP: false)
configuration.joinOnce = true

NEHotspotConfigurationManager.shared.apply(configuration) { (error) in
    if error != nil {
        if error?.localizedDescription == "already associated."
        {
            print("Connected")
        }
        else{
            print("No Connected")
        }
    }
    else {
        print("Connected")
    }
}
Thankful Turkey