Skip to content

Instantly share code, notes, and snippets.

@alladinian
Last active October 24, 2019 13:31
Show Gist options
  • Save alladinian/9b49b95f298f4ab25df9db0e9717a73e to your computer and use it in GitHub Desktop.
Save alladinian/9b49b95f298f4ab25df9db0e9717a73e to your computer and use it in GitHub Desktop.
DONT USE THIS EVER
import UIKit
import PlaygroundSupport
var addresses = Set<String>()
class MyCell: UITableViewCell {
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
let add = "\(Unmanaged.passUnretained(self).toOpaque())"
addresses.insert(add)
}
}
class MyController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(MyCell.self, forCellReuseIdentifier: "cell")
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 100
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 300
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? MyCell else { fatalError() }
return cell
}
}
PlaygroundPage.current.liveView = MyController()
print(addresses)
print(addresses.count)
// Prints 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment