The current code I'm having doens't seem to return anything, I can't find out what is causing the issue.
func getQuests(category: NSString, count: Int) -> NSArray {
var quests = NSArray()
Alamofire.request(.GET, apiUrlString, parameters: ["category": category, "count": count])
.responseJSON { (request, response, json, error) in
dispatch_async(dispatch_get_main_queue(), {
quests = json as NSArray
})
}
println(quests) #=> ()
return quests
}
Does anybody know how to solve the issue I'm having?
[Update]: This is the status.
Please look at the fifth and eight row. I can't get the assignment to quests work.
var quests = NSArray()
getQuests("normal", count: 30, completionHandler: {
quests in
self.quests = quests
})
println(self.quests) #=> ()
func getQuests(category: NSString, count: Int, completionHandler: (NSArray -> Void)) {
var quests = NSArray()
Alamofire.request(.GET, apiUrlString, parameters: ["category": category, "count": count])
.responseJSON { (request, response, json, error) in
dispatch_async(dispatch_get_main_queue(), {
quests = json as NSArray
completionHandler(quests)
})
}
}
Thanks.