Swift weakSelf in closure syntax

前端 未结 2 1368
栀梦
栀梦 2021-02-06 12:46

I have this code to get JSON:

Alamofire.request(.GET, worlds).responseJSON { (request, response, JSON, error) in
        println(JSON)
        //weakSelf.serverL         


        
2条回答
  •  天命终不由人
    2021-02-06 13:19

    You can declare a weak self reference by putting [weak self] before your closure parameters.

    You can see the documentation here

提交回复
热议问题