Skip to content

Instantly share code, notes, and snippets.

@Nicholas-Swift
Created January 25, 2017 07:51
Show Gist options
  • Save Nicholas-Swift/9c549c358dbeffd3d0b800f3400cccfd to your computer and use it in GitHub Desktop.
Save Nicholas-Swift/9c549c358dbeffd3d0b800f3400cccfd to your computer and use it in GitHub Desktop.
//
// 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