Created
September 16, 2018 20:24
-
-
Save diskball/e29a77889aab98ff31c3e7bfade559a1 to your computer and use it in GitHub Desktop.
LogsViewController class
This file contains hidden or 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
| // | |
| // LogsViewController.swift | |
| // Realm Logger | |
| // | |
| // Created by George Bafaloukas on 12/09/2018. | |
| // Copyright © 2018 George Bafaloukas. All rights reserved. | |
| // | |
| import UIKit | |
| class LogUITableViewCell: UITableViewCell { | |
| @IBOutlet weak var logLabel: UILabel! | |
| } | |
| class LogsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
| @IBOutlet weak var logsTableView: UITableView! | |
| var realmLogger: RealmLogger? | |
| var logsArray: [RealmLog]? | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| if let logs = realmLogger?.realm?.objects(RealmLog.self) { | |
| self.logsArray = Array(logs) | |
| self.logsTableView.reloadData() | |
| } | |
| } | |
| // MARK: - UITableViewDelegate, UITableViewDataSource | |
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| return self.logsArray?.count ?? 0 | |
| } | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let cell = tableView.dequeueReusableCell(withIdentifier: "LogUITableViewCell", for: indexPath) as! LogUITableViewCell | |
| cell.logLabel.text = self.logsArray?[indexPath.row].message | |
| return cell | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment