daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Nov 18th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import UIKit
  2.  
  3. class ViewController: UIViewController {
  4.     @IBOutlet weak var textField: UITextField!
  5.     @IBOutlet weak var sentimentLabel: UILabel!
  6.    
  7.     override func viewDidLoad() {
  8.         super.viewDidLoad()
  9.         self.sentimentLabel.text = SentimentAnalyzer.shared.emoji(forScore: 0)
  10.     }
  11.    
  12.     @IBAction func textDidChange(_ sender: Any) {
  13.         if let text = textField.text {
  14.             SentimentAnalyzer.shared.analyze(text) { (score) in
  15.                 self.sentimentLabel.text = SentimentAnalyzer.shared.emoji(forScore: score)
  16.             }
  17.         }
  18.     }
  19. }
RAW Paste Data
Top