Created
January 25, 2017 07:51
-
-
Save Nicholas-Swift/9c549c358dbeffd3d0b800f3400cccfd to your computer and use it in GitHub Desktop.
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
// | |
// BetterTableViewController.swift | |
// TableViewMemoryManagement | |
// | |
// Created by Nicholas Swift on 1/24/17. | |
// Copyright © 2017 Nicholas Swift. All rights reserved. | |
// | |
import UIKit | |
import AlamofireImage | |
class BetterTableViewController: UIViewController { | |
// MARK: - Instance Vars | |
@IBOutlet weak var tableView: UITableView! | |
// MARK: - View Lifecycle | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
tableViewSetup() | |
} | |
} | |
// MARK: - Setup | |
extension BetterTableViewController { | |
func tableViewSetup() { | |
tableView.rowHeight = UITableViewAutomaticDimension | |
tableView.estimatedRowHeight = 350 | |
// NOTE: - Registering the cell programmatically | |
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "BetterTableViewCell") | |
} | |
} | |
// MARK: - Table View Delegate | |
extension BetterTableViewController: UITableViewDelegate { | |
} | |
// MARK: - Table View Data Source | |
extension BetterTableViewController: UITableViewDataSource { | |
func numberOfSections(in tableView: UITableView) -> Int { | |
return 1 | |
} | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return 1000 | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "BetterTableViewCell") | |
cell?.textLabel?.text = "Wow much better" | |
return cell! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment