Created
September 16, 2018 20:26
-
-
Save diskball/ade744434be0849b0ff1c68eb814907a to your computer and use it in GitHub Desktop.
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
| // | |
| // ViewController.swift | |
| // Realm Logger | |
| // | |
| // Created by George Bafaloukas on 12/09/2018. | |
| // Copyright © 2018 George Bafaloukas. All rights reserved. | |
| // | |
| import UIKit | |
| class ViewController: UIViewController { | |
| @IBOutlet weak var logTextField: UITextField! | |
| var realmLogger: RealmLogger? | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| self.realmLogger = RealmLogger(name: "") | |
| } | |
| @IBAction func saveLogAction(_ sender: Any) { | |
| guard let message = self.logTextField.text, message.count > 0 else { | |
| print("Message is empty") | |
| return | |
| } | |
| self.realmLogger?.log(message) | |
| } | |
| @IBAction func gotoLogsAction(_ sender: Any) { | |
| self.performSegue(withIdentifier: "goToLogs", sender: self) | |
| } | |
| // MARK: Navigation | |
| override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
| if let destination = segue.destination as? LogsViewController { | |
| destination.realmLogger = self.realmLogger | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment