Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8274291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:41:35+00:00 2026-06-08T07:41:35+00:00

I’d like to have a BaseViewController class (that inherits from UIViewController ) for my

  • 0

I’d like to have a BaseViewController class (that inherits from UIViewController) for my project that can act as a base class for other view controllers in my project. This is to add things such as a common progress HUD, a refresh button & network updating mechanism, perhaps an error dialog that can be customized with text by each subclass, etc.

Crucially, I want to be able to add this functionality to both UIViewController subclasses AND UITableViewController subclasses, but I’m unable to insert myself into the UITableViewController class hierarchy, so effectively I need a BaseUIViewController and a BaseUITableViewController, but if I do this I have to implement the changes twice and keep them in sync.

What’s the best approach to have a single place for common code that has to be accessible both to BaseViewController subclasses and to BaseTableViewController subclasses? I only want one place in my code where I would have to deal with common tasks.

1) I’ve thought about using a category with associative references, but the problem here is that I need to have custom implementation of the ViewController lifecycle classes such as viewDidLoad:, and it’s not a good idea.

2) I could skip UITableViewController entirely, and build up my own BaseTableViewController from a BaseViewController, implementing tableView delegate & datasource methods myself, but I’m not so keen to skip apple’s controller implementation here.

3) I could have a BaseViewController inheriting from UIViewController, BaseTableViewController inheriting from UITableViewController, and just put custom method calls into a third file ViewControllerBaseMethods that can be invoked from both ‘Base’ files. There might still be duplication of properties, but at least the method code would be in one place.

Any other good approaches for this type of thing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:41:36+00:00Added an answer on June 8, 2026 at 7:41 am

    All UITableViewController does is provide a UITableView property, declare itself as the delegate and data source, and set its view as the table view

    so create a BaseTableViewController which extends BaseViewController, declare it as a UITableViewDataSource and UITableViewDelegate and implement the required methods, add a UITableView property and implement loadView:

    - (void)loadView
    {
        self.tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] andStyle:UITableViewStylePlain];
        self.tableView.delegate = self;
        self.tableView.datasource = self;
        self.view = self.tableView;
    }
    

    if you want to use different table view styles, you can provide a common method or property to take the table view style from when initialising

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a view passing on information from a database: def serve_article(request, id): served_article
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.