方法1、
weak var weakSelf =self
self.block = {() -> () in
if let strongSelf = weakSelf {
//使用self
}
}
方法2、
self.block = {[weak self]() -> () in
//使用self?
}
方法1、
weak var weakSelf =self
self.block = {() -> () in
if let strongSelf = weakSelf {
//使用self
}
}
方法2、
self.block = {[weak self]() -> () in
//使用self?
}
本文标题:【Swift】block防止self循环引用
本文链接:https://www.haomeiwen.com/subject/xloyxrtx.html
网友评论