I have this code
func presentationlum() {
let request = NSMutableURLRequest(URL: NSURL(string: "http://raspberrypi.local/etatlum.php")!)
let Session = NSURLSession.sharedSession()
request.HTTPMethod = "GET"
var JsonDict : NSArray = []
let dem = Session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in
do {
if let _JsonDict = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions() )as? NSArray
{
JsonDict = _JsonDict
if JsonDict[0] as! String == "0"{
Dark1.hidden=true
} else {
Dark1.hidden=false
}
} else {
print("Cannot parse JSON answer")
}
} catch {
print("An Error as occurred : \(error)")
}
print(JsonDict)
})
dem.resume()
}
I want to get the response of my server and use it to hide the UIButton Dark1.
But it doesn't work how can I fix it ?