-
-
Save MochaTheCoder/628af8950f39e5fc0896cc12d77c6fb2 to your computer and use it in GitHub Desktop.
reloadData Handler cellForRowAt debug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
window = UIWindow(frame: UIScreen.main.bounds) | |
let aVC = AViewController() | |
let nav = UINavigationController(rootViewController: aVC) | |
window!.rootViewController = nav | |
window!.makeKeyAndVisible() | |
return true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class BViewController: UIViewController { | |
@IBOutlet var handlerButton: UIButton! { | |
didSet { | |
handlerButton.addTarget(self, action: #selector(doHandler), for: .touchUpInside) | |
} | |
} | |
var handler: (() -> Void) = {} | |
override func viewWillDisappear(_ animated: Bool) { | |
super.viewWillDisappear(animated) | |
print("Disappearing") | |
} | |
@objc private func doHandler() { | |
handler() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class AViewController: UIViewController { | |
@IBOutlet var pushButton: UIButton! { | |
didSet { | |
pushButton.addTarget(self, action: #selector(pushBVC), for: .touchUpInside) | |
} | |
} | |
@IBOutlet var tableView: UITableView! { | |
didSet { | |
tableView.dataSource = self | |
} | |
} | |
@objc private func pushBVC() { | |
let bVC = BViewController() | |
bVC.handler = { | |
print("handling") | |
self.tableView.reloadData() | |
} | |
navigationController?.pushViewController(bVC, animated: true) | |
} | |
} | |
extension AViewController: UITableViewDataSource { | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return 20 | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
print("CellForROwAt") | |
return UITableViewCell() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment