class func getAllProjects(DOMAIN: String) -> JSON{
var hovno: JSON?
Alamofire.request(.GET, "https://\(DOMAIN).projektove.cz/projects.json")
.responseJSON { (request, response, JSONresponse, error) in
if( error == nil){
var responseJSON = JSONresponse as NSMutableDictionary
let json = JSON(responseJSON)
var projects = json["projects"] //Pole projektů
for (index: String, subJson: JSON) in projects {
println(subJson)
hovno = subJson
//mam cisty format JSONu, kazdy projekt zvlast v zavorkach
}
// var data = Projects(json: json).toDictionary()
}else{
println(error)
}
}
return hovno!
}
Why is variable hovno still nil? his would work in every normal language. I declar variable in the beginning and then overwriting it with value subJson. In the end, I just return it. Why is this so hard in Swift and why is this happening? How can I return value?