Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to set a custom class for UITableViewController in Xcode

Xcode will not let me set the custom class of my table view to the following class(when I go to set it on the storyboard it does not let me and nothing comes up on the drop down).

The following is my swift file for my table view controller.

https://gist.github.com/JudeMolloy/139e91d8c45ebe3d6140139ffd68a339

Here is a picture of my storyboard: enter image description here

Thanks.

like image 616
Jude Molloy Avatar asked Aug 29 '26 09:08

Jude Molloy


1 Answers

Check If your class has at least these methods:

//
//  MyCustomTableViewController.swift
//  Test Table
//
//  Created by shadowsheep on 17/02/2018.
//  Copyright © 2018 shadowsheep. All rights reserved.
//

import UIKit

class MyCustomTableViewController: UITableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 0
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 0
    }

}

With these basic stub you shold be able to access your controller for a UITableViewController for sure...

Edit From the new info provided: You must select the UITableViewController and not the UiTableView. Once selected your UITableViewController yoy will be able to set your custom controller.

enter image description here

You'll see you have selected the right class because the light grey default class provided on the Identity Inspector is UITableViewController

Than you can find your custom controller in the dropdown menu.

enter image description here

like image 137
shadowsheep Avatar answered Aug 31 '26 19:08

shadowsheep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!