Channel List

The ChannelListViewController contains a simple TableView that shows a list of Channels. This section will only deal with the essential functionality and not styling.

Set up the TableView like so in your viewDidLoad:


// This is the data backing the TableView
var channels = [ParticipatedChannel]()

override func viewDidLoad() {
    super.viewDidLoad()
    
    // Get the AppDelegate which contains the Mitter object
    let appDelegate = UIApplication.shared.delegate as! AppDelegate
    
    // TableView setup
    ...
    
    // Fetch the list of channels and display
    appDelegate.mitter.channels.getChannelsForCurrentUser {
        result in
        switch result {
        case .success(let fetchedChannels):
            self.channels = fetchedChannels
            print("Received all channels for logged in user")
            self.tableView.reloadData()

        case .error:
            print("Couldn't fetch all channels for logged in user")
        }
    }
}

To render the cell, modify the UITableViewDelegate function as follows:

To open the ChannelWindowViewController on clicking a cell:

Last updated