Created
November 16, 2017 22:52
-
-
Save jfahrenkrug/8166167eb971c8a58ed99c95aa20ec85 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
import UIKit | |
class ViewController: UIViewController { | |
@IBOutlet weak var textField: UITextField! | |
@IBOutlet weak var sentimentLabel: UILabel! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.sentimentLabel.text = SentimentAnalyzer.shared.emoji(forScore: 0) | |
} | |
@IBAction func textDidChange(_ sender: Any) { | |
if let text = textField.text { | |
SentimentAnalyzer.shared.analyze(text) { (score) in | |
self.sentimentLabel.text = SentimentAnalyzer.shared.emoji(forScore: score) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment