Last active
August 8, 2018 19:00
-
-
Save vasarhelyia/70b2c3fae2bbe38c4a7a to your computer and use it in GitHub Desktop.
Brew MVC
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
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