Skip to content

Instantly share code, notes, and snippets.

@vasarhelyia
Last active August 8, 2018 19:00
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vasarhelyia/70b2c3fae2bbe38c4a7a to your computer and use it in GitHub Desktop.
Save vasarhelyia/70b2c3fae2bbe38c4a7a to your computer and use it in GitHub Desktop.
Brew MVC
class Brew {
var temp = 0.0
}
class BrewViewController: UIViewController {
@IBOutlet weak var tempLabel: UILabel!
var brew = Brew()
override func viewDidLoad() {
super.viewDidLoad()
SIOSocket.socketWithHost("http://brewcore-demo.herokuapp.com", response: {socket in
socket.on("temperature_changed", callback: {(AnyObject data) -> Void in
self.brew.temp = data[0] as Float
dispatch_async(dispatch_get_main_queue(), {
self.updateTempLabel()
})
})
})
}
func updateTempLabel() {
self.brewLabel.text = NSString(format:"%.2f ˚C", self.brew.temp)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment