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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:36:48+00:00 2026-06-15T18:36:48+00:00

At the moment I fill my cells using this method: – (UITableViewCell *)tableView:(UITableView *)tableView

  • 0

At the moment I fill my cells using this method:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    // builds the settingsView tableView
    if (menuList) {
        static NSString *cellIdentifier = @"coachingCell";

        UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        if (!contentLoaded) {
            numberOfCells = 0;
        }
        if (contentLoaded) {
            [cell.textLabel setText:[names objectAtIndex:numberOfCells]];
            NSLog(@"Entries: %@", [names objectAtIndex:numberOfCells]);
            if (numberOfCells == [names count]) {
                numberOfCells = 0;
            }
        numberOfCells ++;
        }
        //add a switch
        coachingSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
        cell.accessoryView = coachingSwitch;
        [coachingSwitch setOn:YES];

        return cell;
    }
    ...

But I get an error if I scroll all to the bottom and then one object to the top. That’s because I fill the cells over a counter: numberOfCells.

Now my question: how can I fix this in order to actualy iterate over my array for the right indexPath.section and indexPath.row?

The names array contains:

2012-12-09 16:34:22.373 Test[18817:c07] Entries: Mein Bauchumfang
2012-12-09 16:34:22.375 Test[18817:c07] Entries: Mein Gewicht
2012-12-09 16:34:22.375 Test[18817:c07] Entries: Mein Entspannungsniveau
2012-12-09 16:34:22.376 Test[18817:c07] Entries: Häufigkeit der Entspannungsmomente
2012-12-09 16:34:22.377 Test[18817:c07] Entries: Rauchverhalten
2012-12-09 16:34:22.378 Test[18817:c07] Entries: Verlangen nach einer Zigarette
2012-12-09 16:34:22.378 Test[18817:c07] Entries: Systolischer Wert
2012-12-09 16:34:22.379 Test[18817:c07] Entries: Diastolischer Wert
2012-12-09 16:34:23.713 Test[18817:c07] Entries: Meine bewusste Ernährung mit Diabetes
2012-12-09 16:34:23.964 Test[18817:c07] Entries: Meine Blutzucker-Werte
2012-12-09 16:34:25.384 Test[18817:c07] Entries: Mein Befinden
2012-12-09 16:34:25.584 Test[18817:c07] Entries: Meine Aktivitäten

this is the multi dimensional array I could also use:

2012-12-09 17:23:06.891 stuff[19161:c07] ArrayList: (
    {
    "Bauchumfang & Gewicht" =         (
        "Mein Bauchumfang",
        "Mein Gewicht"
    );
    "Blutdruck & Puls" =         (
        "Systolischer Wert",
        "Diastolischer Wert"
    );
    "Blutzucker & Diabetes" =         (
        "Meine bewusste Ern\U00e4hrung mit Diabetes",
        "Meine Blutzucker-Werte"
    );
    "Mein Rauchverhalten" =         (
        Rauchverhalten,
        "Verlangen nach einer Zigarette"
    );
    "Meine Stimmung" =         (
        "Mein Befinden",
        "Meine Aktivit\U00e4ten"
    );
    "R\U00fccken & Bewegung" =         (
        "Umsetzung meiner R\U00fccken\U00fcbungen",
        "Das Befinden meines R\U00fcckens",
        "Meine sportlichen Aktivit\U00e4ten"
    );
    Schlafrhythmus =         (
        "Meine Schlafqualit\U00e4t",
        "Mein Energieniveau"
    );
    "Schrittz\U00e4hler" =         (
        "Meine Schritte"
    );
    "Stress & Entspannung" =         (
        "Mein Entspannungsniveau",
        "H\U00e4ufigkeit der Entspannungsmomente"
    );
}
)
  • 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-15T18:36:49+00:00Added an answer on June 15, 2026 at 6:36 pm

    Why don’t you just use indexPath.row instead of numberOfCells:

    [cell.textLabel setText:[names objectAtIndex:indexPath.row]];
    

    EDIT:

    You could get the suitable array index using:

    int rowsUntilHere=indexPath.row;
     for (int i=0;i<indexPath.section;i++){
       rowsUntilHere+=[tableView numberOfRowsInSection:i];
       //rowsUntilNow++; //If the array contains the section titles too
     }
    
     [cell.textLabel setText:[names objectAtIndex:rowsUntilHere]];
    

    Hope this helps

    Hoffe das hilft

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

Sidebar

Related Questions

I would like to draw a table using System.Drawings, and then fill cells with
I want to fill up my custom tableview cells with 5 different imageviews. In
At moment I want to implement picture upload without using any plug-ins. My upload
At the moment I'm using bat file to launch my jar and set the
At the moment I'm using all sorts of if statements and substrings in order
for the moment the script does like this: click on the link edit the
I need to fill a UITableView from an NSSet data source. Obviously I want
At the moment, I have this DIV with a registration form centered over the
How do I get this listbox to be maxiumum size, i.e. fill the group
In the application I'm developing at the moment I'm using a datagridview to display

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.