Skip to content

Instantly share code, notes, and snippets.

@RommelTJ
Created April 22, 2015 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RommelTJ/ef076e4fbe1cff90c09b to your computer and use it in GitHub Desktop.
Save RommelTJ/ef076e4fbe1cff90c09b to your computer and use it in GitHub Desktop.
WKInterfaceController.openParentApplication(["content": "isLoggedIn"], reply: { (reply, error) -> Void in
if let response = reply as? [String:String] {
if let loggedIn = response["loggedIn"] {
if loggedIn == "true" {
WKInterfaceController.openParentApplication(["content": "getMessages"], reply: { (reply, error) -> Void in
if let response = reply as? [String:[String]] {
if let messages = response["messages"] {
self.table.setHidden(false)
self.table.setNumberOfRows(messages.count, withRowType: "TableRowController")
//Dispatching on main Queue due to Apple bug.
dispatch_async(dispatch_get_main_queue(), { () -> Void in
for (index, message) in enumerate(messages) {
let row = self.table.rowControllerAtIndex(index) as! TableRowController
row.tableRowLabel.setText(message)
}
})
}
}
})
} else {
self.loginMessage.setHidden(false)
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment