Created
April 22, 2015 18:55
-
-
Save RommelTJ/ef076e4fbe1cff90c09b to your computer and use it in GitHub Desktop.
This file contains 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
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