I have this code to get JSON:
Alamofire.request(.GET, worlds).responseJSON { (request, response, JSON, error) in
println(JSON)
//weakSelf.serverL
You can declare a weak self reference by putting [weak self]
before your closure parameters.
You can see the documentation here
Use the capture list. The correct syntax is:
Alamofire.request(.GET, worlds).responseJSON { [unowned self] (request, response, JSON, error) in
println(JSON)
self.serverList = JSON
}
However take a note that you are not creating retain cycle here, so you do not have to use weak
or unowned
self here. Good article on this topic: http://digitalleaves.com/blog/2015/05/demystifying-retain-cycles-in-arc/