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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:32:53+00:00 2026-06-02T21:32:53+00:00

I’m stuck with a problem populating an UITableView . I have got an NSMutableArray

  • 0

I’m stuck with a problem populating an UITableView.
I have got an NSMutableArray with customers. It looks like this:

customer
    first letter="A"
    customer name="Adwars Inc."
customer
        first letter="A"
        customer name="Amman Co."
customer
        first letter="B"
        customer name="Building Inc."
customer
        first letter="C"
        customer name="Computer Co."

So I’ve got an object customer, which separates me each customer. And i’ve got some keys for each object.
In my second NSArray i’ve got all my first letters, which appear in my customer data. It look like this:

A
B
C
D
G
J
M
S
Z

I was able to get my right section count and rows in section, but when i try to populate my table view it always look like this:

SCREENSHOT

HERE IS MY CODE

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

static NSString *MyIdentifier = @"CustomerCell";

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

for(int i = 0; i < [firstletters count]; i++)
{
    if (indexPath.section == i) {

        for(int count = 0 ;count < [customers count]; count++)
        {

        NSString *firstletter;
        NSString *key;

        key = [firstletters objectAtIndex:indexPath.section];
        firstletter = [[customers objectAtIndex:count] objectForKey: @"FirstLetter"];
            if ([key isEqualToString:firstletter]) {
                cell.textLabel.text = [[customers objectAtIndex:count] objectForKey: @"S_NAME1"];
                cell.detailTextLabel.text = [[customers objectAtIndex:count] objectForKey: @"s_town"];
            }

        }
    }
}

return cell;
}

What do i have to do to make it work?

  • 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-02T21:32:56+00:00Added an answer on June 2, 2026 at 9:32 pm

    For every cell, you’re iterating through all the customers, repeatedly setting (and resetting) the textLabel and detailTextLabel for every customer whose first letter matches the current section (but you’re not considering whether the index of that customer in that section matches the current indexPath.row or not). This means that in your code every cell will have the textLabel and detailTextLabel for the last customer whose first letter matches the current section’s first letter.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
link Im having trouble converting the html entites into html characters, (&# 8217;) 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.