// The channel id for this Channel. This will be set by ChannelListViewController
// 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
// Hook up the Send button
sendButton.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside)
// Fetch all Messages in Channel
appDelegate.mitter.messaging.getMessagesInChannel(channelId) {
case .success(let fetchedMessages):
self.messages = fetchedMessages.reversed()
self.tableView.reloadData()
print("Couldn't fetch messages")