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

  • SEARCH
  • Home
  • 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 8963803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:26:21+00:00 2026-06-15T16:26:21+00:00

i’m working on table view for last few days. but, now i’m stuck. actually,

  • 0

i’m working on table view for last few days. but, now i’m stuck. actually, what m i doin’ is that i i want to store cell indexes into a mutable array. i’d done this part. but, as i scroll the table view, the data stored in the array gets refreshed and the indexes that i stored gets removed from that mutable array. here’s the code what i have done so far….

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {

    if (tableView == table1) {
    static NSString *CellIdentifier = @”Cell”;

    NSString *CellId = [NSString stringWithFormat:@"Cell %d",indexPath.row];
    
    CellIdentifier = CellId;
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if (cell == nil)
    
    {                
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    }
    NSUserDefaults *defaults1 = [NSUserDefaults standardUserDefaults];
    NSString *loadname1 = [defaults1 objectForKey:@"name1saved"];
    
    NSUserDefaults *defaults2 = [NSUserDefaults standardUserDefaults];
    NSString *loadname2 = [defaults2 objectForKey:@"name2saved"];
    
    NSUserDefaults *defaults3 = [NSUserDefaults standardUserDefaults];
    NSString *loadname3 = [defaults3 objectForKey:@"name3saved"];
    
    NSUserDefaults *defaults4 = [NSUserDefaults standardUserDefaults];
    NSString *loadname4 = [defaults4 objectForKey:@"name4saved"];
    
    NSUserDefaults *defaults5 = [NSUserDefaults standardUserDefaults];
    NSString *loadname5 = [defaults5 objectForKey:@"name5saved"];
    
    NSUserDefaults *defaults6 = [NSUserDefaults standardUserDefaults];
    NSString *loadname6 = [defaults6 objectForKey:@"name6saved"];
    
    NSUserDefaults *defaults7 = [NSUserDefaults standardUserDefaults];
    NSString *loadname7 = [defaults7 objectForKey:@"name7saved"];
    
    NSUserDefaults *defaults8 = [NSUserDefaults standardUserDefaults];
    NSString *loadname8 = [defaults8 objectForKey:@"name8saved"];
    
    NSUserDefaults *defaults9 = [NSUserDefaults standardUserDefaults];
    NSString *loadname9 = [defaults9 objectForKey:@"name9saved"];
    
    NSUserDefaults *defaults10 = [NSUserDefaults standardUserDefaults];
    NSString *loadname10 = [defaults10 objectForKey:@"name10saved"];
    
    NSUserDefaults *defaults11 = [NSUserDefaults standardUserDefaults];
    NSString *loadname11 = [defaults11 objectForKey:@"name11saved"];
    
    NSUserDefaults *defaults12 = [NSUserDefaults standardUserDefaults];
    NSString *loadname12 = [defaults12 objectForKey:@"name12saved"];
    
    NSUserDefaults *defaults13 = [NSUserDefaults standardUserDefaults];
    NSString *loadname13 = [defaults13 objectForKey:@"name13saved"];
    
    NSUserDefaults *defaults14 = [NSUserDefaults standardUserDefaults];
    NSString *loadname14 = [defaults14 objectForKey:@"name14saved"];
    
    NSUserDefaults *defaults15 = [NSUserDefaults standardUserDefaults];
    NSString *loadname15 = [defaults15 objectForKey:@"name15saved"];
    
    NSUserDefaults *defaults16 = [NSUserDefaults standardUserDefaults];
    NSString *loadname16 = [defaults16 objectForKey:@"name16saved"];
    
    NSUserDefaults *defaults17 = [NSUserDefaults standardUserDefaults];
    NSString *loadname17 = [defaults17 objectForKey:@"name17saved"];
    
    NSUserDefaults *defaults18 = [NSUserDefaults standardUserDefaults];
    NSString *loadname18 = [defaults18 objectForKey:@"name18saved"];
    
    NSUserDefaults *defaults19 = [NSUserDefaults standardUserDefaults];
    NSString *loadname19 = [defaults19 objectForKey:@"name19saved"];
    
    NSUserDefaults *defaults20 = [NSUserDefaults standardUserDefaults];
    NSString *loadname20 = [defaults20 objectForKey:@"name20saved"];
    
    mTFArrayOfNames = [[NSMutableArray alloc]init ];
    
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname1] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname2] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname3] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname4] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname5] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname6] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname7] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname8] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname9] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname10] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname11] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname12] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname13] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname14] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname15] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname16] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname17] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname18] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname19] atIndex:[mTFArrayOfNames count]] ;
    [mTFArrayOfNames insertObject:[NSString stringWithFormat:@"%@", loadname20] atIndex:[mTFArrayOfNames count]] ;
    
    NSLog(@"%@", mTFArrayOfNames);
    
    if (indexPath.row == 0) {
    
        cell.textLabel.text = loadname1;
    }
    
    if (indexPath.row == 1) {
        cell.textLabel.text = loadname2;
    }
    
    if (indexPath.row == 2) {
        cell.textLabel.text = loadname3;
    }
    if (indexPath.row == 3) {
        cell.textLabel.text = loadname4;
    }
    if (indexPath.row == 4) {
    
        cell.textLabel.text = loadname5;
    }
    
    if (indexPath.row == 5) {
        cell.textLabel.text = loadname6;
    }
    
    if (indexPath.row == 6) {
        cell.textLabel.text = loadname7;
    }
    if (indexPath.row == 7) {
        cell.textLabel.text = loadname8;
    }
    
    if (indexPath.row == 8) {
    
        cell.textLabel.text = loadname9;
    }
    
    if (indexPath.row == 9) {
        cell.textLabel.text = loadname10;
    }
    
    if (indexPath.row == 10) {
        cell.textLabel.text = loadname11;
    }
    if (indexPath.row == 11) {
        cell.textLabel.text = loadname12;
    }
    if (indexPath.row == 12) {
    
        cell.textLabel.text = loadname13;
    }
    
    if (indexPath.row == 13) {
        cell.textLabel.text = loadname14;
    }
    
    if (indexPath.row == 14) {
        cell.textLabel.text = loadname15;
    }
    if (indexPath.row == 15) {
        cell.textLabel.text = loadname16;
    }
    if (indexPath.row == 16) {
    
        cell.textLabel.text = loadname17;
    }
    
    if (indexPath.row == 17) {
        cell.textLabel.text = loadname18;
    }
    
    if (indexPath.row == 18) {
        cell.textLabel.text = loadname19;
    }
    if (indexPath.row == 19) {
        cell.textLabel.text = loadname20;
    }
    
    
    
    cell.textLabel.font = [UIFont fontWithName:@"Bauhaus 93" size:18];
    cell.textLabel.textColor = [UIColor whiteColor];
    cell.textLabel.backgroundColor = [UIColor grayColor];
    [cell.textLabel setTextAlignment:UITextAlignmentCenter];
    
    return cell;
    

    }
    }

  • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {

    if (tableView == table1) {
    UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];

    if ([selectedCell accessoryType] == UITableViewCellAccessoryNone) {
        [selectedCell setAccessoryType:UITableViewCellAccessoryCheckmark];
    
        [selectedIndexes addObject:[NSNumber numberWithInt:indexPath.row]];
        selectedCell.backgroundColor =[UIColor blueColor];
    
    } else {
        [selectedCell setAccessoryType:UITableViewCellAccessoryNone];
    
        [selectedIndexes removeObject:[NSNumber numberWithInt:indexPath.row]];
    
        selectedCell.backgroundColor =[UIColor clearColor];
    
    }
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
    
    names = [[NSMutableArray alloc] init];
    
    for (int i = 0; i < mTFArrayOfNames.count; i++)
    {
        if ([self.table1 cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]].accessoryType == UITableViewCellAccessoryCheckmark) 
        {
            [names addObject:[mTFArrayOfNames objectAtIndex:i]];
    
      }
        NSLog(@"name1 is  %@", names);
    }
    

}
}
Please help me. thankx 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-15T16:26:22+00:00Added an answer on June 15, 2026 at 4:26 pm

    Is it the names MutableArray that is getting refreshed ?
    If so, it is because you are initializing it everytime a cell is selected. Thus ending up in deleting the previously set value.

    • Initialize the names array outsite the delegate. maybe in viewDidLoad or where ever you intialize the TableView

    • In didSelect, add the new object in the names array

    Also, it is bad logic to create all the loadnameX in the cellForRowAtIndexPath and add to newly initialized mTFArrayOfNames.

    • Remove this entire logic from cellForRowAtIndexPath and add it to viewDidLoad or where ever you intialize the TableView
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,

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.