習(xí)慣了oc 的寫(xiě)法城菊,在此記錄一下swift 的寫(xiě)法。
第一種寫(xiě)法
request.responseString(encoding: NSUTF8StringEncoding) {[weak self] (res) -> Void in
if let strongSelf = self {
//do something...
}
}
第二種寫(xiě)法
weak var weakSelf = self
request.responseString(encoding: NSUTF8StringEncoding) {(res) -> Void in
if let strongSelf = weakSelf {
//do something
}
}