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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:38:18+00:00 2026-05-26T23:38:18+00:00

i went table view change content depend on SegmentIndex – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath

  • 0

i went table view change content depend on SegmentIndex

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

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

    // Set up the cell
    book *bok = (book *)[self.booktable objectAtIndex:indexPath.row];

    NSArray *rowoftitle = [NSArray arrayWithObjects:bok.book_title, nil];
    NSArray *rowofauth = [NSArray arrayWithObjects:bok.author_name, nil];
    NSArray *rowofpub = [NSArray arrayWithObjects:bok.pub_name, nil];

    //[cell setText:bok.book_title];
    [tableView beginUpdates];

    switch (segControl.selectedSegmentIndex) 
    {
        case 0:
        [tableView insertRowsAtIndexPaths:rowoftitle withRowAnimation:UITableViewRowAnimationTop];

        //cell.textLabel.text =bok.book_title; 
        break;

    case 1:
        [tableView insertRowsAtIndexPaths:rowofauth withRowAnimation:UITableViewRowAnimationTop];


        //[libraryTV reloadData];
        //cell.textLabel.text =bok.author_name;
        break;
    case 2:
        [tableView insertRowsAtIndexPaths:rowofpub withRowAnimation:UITableViewRowAnimationTop];

        //cell.textLabel.text =bok.pub_name;
        break;

    default:
        break;          
}

    [tableView endUpdates];
    //return cell;  
}

but when run it the expiation is happen :

‘NSInvalidArgumentException’, reason: ‘-[NSCFString row]: unrecognized
selector sent to instance 0x5d84f80

how resolve it.

  • 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-26T23:38:19+00:00Added an answer on May 26, 2026 at 11:38 pm

    One solution could be:

    You will need to use a common datasource (in this code I am using dataSourceArray for this purpose, you will need to declare it in header file and alloc/init in viewDidLoad method.), which will be updated on changing the segment.
    It will have following method.(for segment change event)

    -(void)segmentSelected:(UISegmentedControl *)sender
    {
        switch (sender.selectedSegmentIndex)
        {
            case 0:
                [self loadTitles];
                break;
            case 1:
                [self loadAuthors];
                break;
            case 2:
                [self loadPublishers];
                break;
            default:
                break;
        }
    }
    
    
    
    
    - (void) loadTitles
    {
        [self.dataSourceArray removeAllObjects];
        for (Book *book in self.booktable) 
        {
            [dataSourceArray addObject:book.book_title];
        }
        [<yourTableViewVariable> reloadData];
    }
    

    Similarly code for other methods loadAuthors and loadPublishers.

    Now your numberOfRowsInSection method will be:

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return [dataSourceArray count];
    }
    

    and cellForRowAtIndexPath will be:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString *CellIdentifier = @"Cell";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];     
        }
    
        // Set up the cell
        cell.textLabel.text = [dataSourceArray objectAtIndex:indexPath.row];
        return cell;  
    }
    

    Thanks

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

Sidebar

Related Questions

I went through a document at Adobe Livedocs that describes working with pdf: http://livedocs.adobe.com/flex/3/html/help.html?content=PDF_1.html
I connected Sqlite3 to my project to UITableview the code went fine But when
I've imported a CSV file into an sqlite table. everything went fine except it
Is there a database term for table or view? In my app, the table
I was trying to follow the Table View Programming Guide for iPhone OS but
I have this in my tableView:cellForRowAtIndexPath: if (condition) { // make a custom cell
I've created my first CLR table valued function. The steps I went through were:
Hi guys I have a table view but I don't want it to fill
I went to all the documentation, also I went to the IRC channel (BTW
I went to school for programming years ago and when I got out I

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.