Channel Window
// The channel id for this Channel. This will be set by ChannelListViewController
var channelId = String()
// The list of Messages in this channel, backing the messages TableView
var messages = [Message]()
override func viewDidLoad() {
// Get the AppDelegate, which contains the Mitter object
let appDelegate = UIApplication.shared.delegate as! AppDelegate
// TableView setup
...
// Hook up the Send button
sendButton.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside)
// Fetch all Messages in Channel
appDelegate.mitter.messaging.getMessagesInChannel(channelId) {
result in
switch result {
case .success(let fetchedMessages):
self.messages = fetchedMessages.reversed()
self.tableView.reloadData()
case .error:
print("Couldn't fetch messages")
}
}
}
}Last updated