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 8409887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:02:24+00:00 2026-06-10T00:02:24+00:00

I have a subclassed UITableView, ‘subclassChild’ which inherits from another subclass ‘subclassParent’. ‘subclassParent’ then

  • 0

I have a subclassed UITableView, ‘subclassChild’ which inherits from another subclass ‘subclassParent’. ‘subclassParent’ then inherits from UITableView.

My view controller inherits from a custom View Controller ‘GenericTableViewController’, and contains my UITableViewController which has the class of ‘subclassChild’.

‘GenericTableViewController’ customises my tables header and footers for all view controllers containing a table view.

My question is, how do I make it so that my UITableView can use ‘subclassChild’ and ‘subclassParent’ as its delegate and dataSource. Still making sure that ‘GenericTableViewController’ customises my tables header and footers.

Sorry if this is a bit confusing, I’ve tried to describe it as well as I can.

P.S I have added <UITabBarDelegate, UITableViewDataSource> in the header files.

And I have made sure that the table inherits from ‘subclassChild’ in IB.

Thanks in advance!

  • 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-10T00:02:25+00:00Added an answer on June 10, 2026 at 12:02 am

    What you can do, is have your ‘GenericTableViewController’ have a delegate itself. It will do most of the work itself, but at the end it shall ask its delegate ‘anything else to do’?

    And when the delegate says ‘Yes, there is something actually’, that code will get executed, serving as data source, delegate or whatever you want it to be. As an example (please forgive me for code inaccuracies):

    - (void) rowForIndex:(NSInteger)row {
         if([delegate respondsToSelector:@selector("TVGetRow:")]) {
              return [delegate TVGetRow:row]
         } else return Rows[row];
    }
    

    This example assumes, that you have an array of tableview cells, but should give you a good idea. You don’t need to implement UITableViewDataSource to that subclass header files, but instead use a custom protocol.

    Edit: Since apparently I was unclear in what I was aiming to do, allow me to add a little information.

    The basic idea is to use ‘subclassChild’ and through it ‘subclassParent’ as delegates for GenericTableViewController, instead of using ‘subclassChild’ as the type for the tableView. (You should never subclass a view, unless you intend to change it’s drawing behaviour).

    The general hierarchy would work like this:

    subclassChild -> delegate -> GenericTableViewController <- DataSource/Delegate <- TableView

    You’d need to create an init method, or a setter method, which sets this delegate, and a simple protocol, which allows you to call functions, like so:

    @interface GenericTableViewController : UITableViewController <UITableViewDataSource, UITableViewDelegate> {
        id theDelegate;
    }
    
        - (id) initWithDelegate:(id)delegate;
    @end
    
    @protocol GTVC
        @optional
        - (UITableViewCell *) getDataForRow:(NSIndexPath *)path;
        - (void) rowSelected:(NSIndexPath *) path;
    @end
    

    In the .m file, this example would look like this:

    @implementation GenericTableViewController
        - (id) initWithDelegate:(id)delegate {
            self = [super initWithNibName:@"TableView.nib" bundle:nil];
            if(self) {
                theDelegate = [delegate retain];  //The 'retain' is optional, really.
            }
            return self;
        }
    
        - (void) dealloc {
            [theDelegate release]; //In case of retain -> release.
        }
    
        - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
            if([theDelegate respondsToSelector:@selector(getDataForRow:)])
                return [theDelegate getDataForRow:indexPath];
            else {
                //Create general UITableViewCell
            }
        }
    
        - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
            if([theDelegate respondsToSelector:@selector(rowSelected:)])
                [theDelegate rowSelected:indexPath];
            else {
                //Do stuff
            }
        }
    @end
    

    This protocol/delegate ‘game’ can be expanded easily, giving you all levels of control you need…all the while with the GenericTableViewController as a ‘backup’, if any delegate isn’t set, or ‘not ready’ to answer the request for further instructions.
    I hope this helps.

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

Sidebar

Related Questions

I have an UIViewController which contains a UITableView (subclassed) and another UIView (subclassed). They
I have an UITableViewController to manage an table view which created with subclassed prototype
in app i have custom tableview(UITableView *tableView) which subclass of uiviewcontroller & in tableview
My view controller will open modal view that is a UITableView subclass. UITableView subclass
So I have a subclassed UITableView that lists data. I need to make only
I have a UITableViewController with a subclass of UITableViewCell with a UITableView in each
We have subclassed the Silverlight Application class to add some additional functionality and then
I have subclassed UIView object inside a uiscrollview which displays a pdf page. I
I have a navigation controller with a table view. In most tutorials I've read
I have a view controller managed in a UINavigationController. My view controller puts up

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.