I have written a function which should return a certain value from a page. I have done this with JSON, so that I can get a certain value from my website. This is the function:
func getTimerData() {
var currentUsername = PFUser.currentUser()!.username
let url = NSURL(string: "http://dinges.informatica-dinges.nl/timerDataTransmitter.php?user=\(currentUsername!)&unique=85017438957")
let request = NSMutableURLRequest(URL: url!)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
data, response, error in
var parseError: NSError?
if let json = NSJSONSerialization.JSONObjectWithData(data!, options: nil, error: &parseError) as? [String: String] {
let rideTime = json["timerValue"]
return rideTime
}
}
}
However, it gives me the error: Unexpected non-void return value in void function
. I have tried a lot but I can't seem to find a way to fix this problem. Do you know how I can fix it?