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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:59:12+00:00 2026-05-26T21:59:12+00:00

I have a NSMutableArray named as records and a NSArray . Now I am

  • 0
  1. I have a NSMutableArray named as records and a NSArray.

  2. Now I am retrieving an XML attribute and its value, using TBXML parser and inserting the attribute value in the NSArray.

  3. This NSArray is an object of records.

What will be the numerberOfRowsInSection when I want to display the value of XML data in tableview cell?

This is my data retrieving procedure….

[records addObject:[NSArray arrayWithObjects:
    [TBXML textForElement:id],
    [TBXML textForElement:productNumber],
    [TBXML textForElement:name],
    [TBXML textForElement:availableStock],
    [TBXML textForElement:image],
    [TBXML textForElement:quantityOrderMin],
    [TBXML textForElement:dateCreated],
    [TBXML textForElement:dateUpdated],nil]];

And my XML data are….

<ProductData HASH="21106941">
    <id>1</id>
    <productNumber>a91cc0f4c7</productNumber>
    <name>Product 1</name>
    <seoTitle>product-1</seoTitle>
    <viewCount>0</viewCount>
    <availableStock>100.0</availableStock>
    <lowStock>0.0</lowStock>
    <image>5e928bbae358c93caedf6115fa7d178b.jpg</image>
    <quantityOrderMax>20.0</quantityOrderMax>
    <dateCreated>2011-10-06T16:08:45</dateCreated>
</ProductData>
<ProductData HASH="409555632">
    <id>2</id>
    <productNumber>d8287e2e51</productNumber>
    <name>Product 2</name>
    <seoTitle>product-2</seoTitle>
    <description>
    <p>Lorem ipsum dolor sit amet, consectetue...</p>
    </description>
    <viewCount>0</viewCount>
    <availableStock>100.0</availableStock>
    <image>8bbd8dfff3cdd28285d07810a4fe7c32.jpg</image>
    <quantityOrderMin>1.0</quantityOrderMin>
    <dateCreated>2011-10-06T16:08:45</dateCreated>
</ProductData>

I am being able to retrieve data in UITableviewCell, but it’s displaying first two retrieved data of the NSArray because the number of rows are two in records array. but i want to set the numberOfRowsInsection will be according to the total number of attribute value retrieved by NSArray.

I have got the problem and I know the problem is here:

  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        NSLog(@"The number of row in the object array:  %d ",[records count]);
        return [records count];
    }

How can I fix 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-26T21:59:13+00:00Added an answer on May 26, 2026 at 9:59 pm
    #pragma mark tableview
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        int sectionCount = [records count];
        NSLog(@"section cout: %d",sectionCount);
        return sectionCount;
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return 1;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString *MyIdentifier = @"MyIdentifier";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
            cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15.0];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
            UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow.png"]];
            cell.accessoryView = imageView;
            cell.accessoryType = UITableViewCellSelectionStyleNone;
            tableView.separatorColor = [UIColor clearColor];
            tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    
            cellView = [[[UIView alloc] initWithFrame:CGRectMake(5,8,290, 120)] autorelease];
            cellView.backgroundColor = [UIColor clearColor];
            cellView.tag =10;
            [cell.contentView addSubview:cellView];
    
            imgView = [[UIImageView alloc] initWithFrame:CGRectMake(2, 40, 48, 48)];
            imgView.image = [UIImage imageNamed:@"productbox.png"];
            imgView.layer.borderColor = [UIColor blackColor].CGColor;
            imgView.layer.borderWidth = 2.0;
            imgView.tag = 5;
            [cellView addSubview:imgView];
    
            CGRect idLabelRect = CGRectMake(65, 0, 190, 18);
            idLabel = [[[UILabel alloc] initWithFrame:idLabelRect] autorelease];
            idLabel.textAlignment = UITextAlignmentLeft;
            idLabel.textColor = [UIColor blackColor];
            idLabel.font = [UIFont systemFontOfSize:12];
            idLabel.backgroundColor = [UIColor clearColor];
            idLabel.layer.borderColor = [UIColor grayColor].CGColor;
            idLabel.tag = 0;
    
            CGRect statusRect = CGRectMake(65, 22, 190, 22);
            statusLabel = [[[UILabel alloc] initWithFrame:statusRect] autorelease];
            statusLabel.textAlignment = UITextAlignmentLeft;
            statusLabel.textColor = [UIColor blackColor];
            statusLabel.font = [UIFont systemFontOfSize:12];
            statusLabel.backgroundColor = [UIColor clearColor];
            statusLabel.layer.borderColor = [UIColor grayColor].CGColor;
            statusLabel.tag = 1;
    
            CGRect orderDateRect = CGRectMake(65, 48, 190, 22);
            orderDate = [[[UILabel alloc] initWithFrame:orderDateRect] autorelease];
            orderDate.textAlignment = UITextAlignmentLeft;
            orderDate.textColor = [UIColor blackColor];
            orderDate.font = [UIFont systemFontOfSize:12];
            orderDate.backgroundColor = [UIColor clearColor];
            orderDate.layer.borderColor = [UIColor grayColor].CGColor;
            orderDate.tag = 2;
    
            CGRect byRect = CGRectMake(65, 75, 190, 22);
            byLabel = [[[UILabel alloc] initWithFrame:byRect] autorelease];
            byLabel.textAlignment = UITextAlignmentLeft;
            byLabel.textColor = [UIColor blackColor];
            byLabel.font = [UIFont systemFontOfSize:12];
            byLabel.backgroundColor = [UIColor clearColor];
            byLabel.layer.borderColor = [UIColor grayColor].CGColor;
            byLabel.tag = 3;
    
            CGRect totalRect = CGRectMake(65, 98, 190, 22);
            totalLabel = [[[UILabel alloc] initWithFrame:totalRect] autorelease];
            totalLabel.textAlignment = UITextAlignmentLeft;
            totalLabel.textColor = [UIColor blackColor];
            totalLabel.font = [UIFont systemFontOfSize:12];
            totalLabel.backgroundColor = [UIColor clearColor];
            totalLabel.layer.borderColor = [UIColor grayColor].CGColor;
            totalLabel.tag = 4;
    
            [cellView addSubview:idLabel];
            [cellView addSubview:statusLabel];
            [cellView addSubview:orderDate];
            [cellView addSubview:byLabel];
            [cellView addSubview:totalLabel];
        }
    
        cellView = (UIView *)[cell.contentView viewWithTag:10];
        idLabel = (UILabel *)[cellView viewWithTag:0];
        statusLabel = (UILabel *)[cellView viewWithTag:1];
        orderDate = (UILabel *)[cellView viewWithTag:2];
        byLabel = (UILabel *)[cellView viewWithTag:3];
        totalLabel = (UILabel *)[cellView viewWithTag:4];
        imgView = (UIImageView *)[cellView viewWithTag:5];
        idLabel.text = [NSString stringWithFormat:@"Order Id: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:0]];
        statusLabel.text = [NSString stringWithFormat:@"Status: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:1]];
        orderDate.text = [NSString stringWithFormat:@"Date: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:2]];
        byLabel.text =[NSString stringWithFormat:@"By: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:3]];
        totalLabel.text =[NSString stringWithFormat:@"Total: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:4]];
    
        return cell;
    }
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        //Get the selected country
        NSString *selectedSection = [ NSString stringWithFormat:@"%@",[[records objectAtIndex:indexPath.section] objectAtIndex:0] ];
        dvController = [[OrderDetailsViewController alloc] initWithNibNameAndCurrentTweetUser:@"OrderDetailsViewController" bundle:nil:selectedSection];
        [self.navigationController pushViewController:dvController animated:YES];
        [dvController release];
        dvController = nil;
    }
    
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        return 130;
    }
    
    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
        UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 20)];
        [v setBackgroundColor:[UIColor blackColor]];
    
        UILabel* hdr = [[[UILabel alloc] initWithFrame:CGRectMake(10,0, tableView.bounds.size.width,20)] autorelease];
        hdr.textAlignment = UITextAlignmentLeft;
        hdr.font = [UIFont fontWithName:@"Arial-BoldMT" size:12];
        hdr.textColor = [UIColor whiteColor];
        hdr.backgroundColor = [UIColor blackColor];
        [v addSubview:hdr];
    
        hdr.text = [NSString stringWithFormat:@"Order #%@",[[records objectAtIndex:section] objectAtIndex:0]];
        return v;
    }
    
    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
        return 20;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have become able to parse the xml url using TBXML parser. parsed data
I have an nsmutablearray named nsmarrMedicineInfo. I want to sort the element by using
I have a NSMutableArray: NSMutableArray *temp = //get list from somewhere. Now there is
I have a class that subclasses NSMutableArray. I init it using: MyClass class =
i have one problem when i sort the NSMutablearray using date and time wise.
I have NSMutableArray with different objects in it of different classes. Now I want
I have NSMutableArray named *arrWords containing list of 50 words. e.g. Bond/Bind/King/Sing/Ring etc. I
I have a custom class named Profile and a NSMutableArray which I add the
I have function named: - (void) AddSortedCustomFeed :(NSMutableArray*) rssList; this function adds items(Articles) from
I Create a class named DataClass there i have this method +(NSMutableArray*) returnList :(NSString

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.