【发布时间】:2020-06-27 13:21:20
【问题描述】:
我有以下引用弱的案例:
function hello(to persons: [Person]) {
/// should persons be also weak below?
helloView.didHelloPressed = { [weak self] someFlag in
self?.configurePersons(persons)
}
}
在上面的代码中,我弱捕获了,我知道self 应该是弱的,因为我使用了它的函数(configurePersons)。但是persons 数组(hello 函数的参数)也应该很弱吗?我认为是的,但我没有清楚地解释它。我想如果self不是nil,那么persons也不会是nil,让它变弱也没有意义。
【问题讨论】:
标签: swift closures automatic-ref-counting weak-references