An example for Swift retain cycle
class BankAccount {
var owner: Owner?
init() {
}
}
class Owner {
var account: BankAccount?
init() {
}
}
let bankAccount = BankAccount()
let owner = Owner()
bankAccount.owner = owner
owner.account = bankAccount
var owner: Owner?
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
weak var owner: Owner?
lazy var configureCell: (UITableViewCell)->() = { cell in
if let tableViewCell = cell as? TableViewCell {
tableViewCell.title?.text = self.name
}
}
lazy var configureCell: (UITableViewCell)->() = { cell in
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
lazy var configureCell: (UITableViewCell)->() = { [unowned self] cell in
var delegate: TableViewCellDelegate?
var delegate: TableViewCellDelegate?
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
weak var delegate: TableViewCellDelegate?