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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:25:51+00:00 2026-05-25T13:25:51+00:00

I have 2 classes for a UITableViewCell that show different data but they use

  • 0

I have 2 classes for a UITableViewCell that show different data but they use the same table.

I’m trying to populate the table in 2 steps by using a bool var, but it seems that I get an exception because the cell gains the first class assignment and can’t mutate…

basicaly I have to cell extended classes

@interface PatientsCellNewPager : UITableViewCell { } 
@interface DoctorsCellNewPager : UITableViewCell { } 

the code brakes when I’m at step 2 and trying to change the type of the cell and gives an exception at [cell setData:set cellid:[NSString stringWithFormat:@"%d",indexPath.row] ];
on the phase==2 if block..

this is because cell according to the debugger still has the type DoctorsCellNewPager from the first initialization….

How can I do it otherwise??
It has to be on the same page using the same instance of the class but using multiple layouts and defining the cell layout the spot ..would be a terrible option

here’s my code

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";



    if (phase==2) { //patient


        PatientsCellNewPager *cell =(PatientsCellNewPager *)  [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[PatientsCellNewPager alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }







        PatientsSet *set = (PatientsSet *)[patients_set objectAtIndex:indexPath.row];       

        NSLog(@"logg %d",indexPath.row);    


        [cell setData:set cellid:[NSString stringWithFormat:@"%d",indexPath.row] ]; 




           return cell;

    }
    else if (phase==1) { //doctor


        DoctorsCellNewPager *cell =(DoctorsCellNewPager *)  [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[DoctorsCellNewPager alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        }





            // Set up the cell

            DoctorsSet *set = (DoctorsSet *)[doctors_set objectAtIndex:indexPath.row];      


              [cell setData:set cellid:[NSString stringWithFormat:@"%d",indexPath.row] pass:YES ];  





        return cell;


    }


    return nil;

}

here’s my error

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DoctorsCellNewPager setData:cellid:]: unrecognized selector sent to instance 0x181690'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x323ef64f __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x36632c5d objc_exception_throw + 24
    2   CoreFoundation                      0x323f31bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
    3   CoreFoundation                      0x323f2649 ___forwarding___ + 508
  • 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-05-25T13:25:52+00:00Added an answer on May 25, 2026 at 1:25 pm

    That’s a very common issue and many people came across that – Just recently I had to deal with that issue, too.

    Matt Gallagher posted a great tutorial on how to accomplish that on his blog:

    Heterogeneous cells in a UITableViewController


    Well, I just got an idea on how it could work..
    // THIS IS HIGHLY EXPERIMENTAL AND HAS NOT BEEN TESTED:

    static NSString *PatientsCellIdentifier = @"PatientsCellNewPager";
    static NSString *DoctorsCellIdentifier = @"DoctorsCellNewPager";
    
    UITableViewCell *cell;
    if(patient) {
        cell = [tableView dequeueReusableCellWithIdentifier:PatientsCellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] 
            initWithStyle:UITableViewCellStyleDefault 
            reuseIdentifier:PatientsCellIdentifier] autorelease];
        }
        // Setup cell for patient -> maybe you could use -configureCell:atIndexPath:
    } else if (doctor) {
        cell = [tableView dequeueReusableCellWithIdentifier:DoctorsCellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] 
            initWithStyle:UITableViewCellStyleDefault 
            reuseIdentifier:DoctorsCellIdentifier] autorelease];
        }
        // Setup cell for doctor -> maybe you could use -configureCell:atIndexPath:
    }
    
    return cell;
    

    Let me know if this brought you any further..

    HTH

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

Sidebar

Related Questions

I have classes that are named exactly the same across different plug-ins that I
I have classes that store data, and methods to go get data for individual
I have classes like the following. That is many classes with the same few
For a math package, I am trying to have classes for different types of
I have classes which have automatic properties only like public customerName {get; set;}. They
I have classes that are needed in both my web service and my server.
I have downloaded a third party library and they have classes I need to
I have a couple of UITableViewController classes and I just noticed that these methods
I often have classes that are mostly just wrappers around some STL container, like
I want to have classes that can mix only specified traits: class Peter extends

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.