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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:17:11+00:00 2026-05-26T02:17:11+00:00

I am newer in iPhone application development. I want to find out why tableview

  • 0

I am newer in iPhone application development. I want to find out why tableview cell is not showing data. I tried a lot of ways. I am giving my code below.

Note that I am seeing data at my console which is coming from XML file but it’s not displaying in UITableView cell.

    
    @synthesize newsTable;
    @synthesize  activityIndicator; 
    @synthesize rssParser; 
    @synthesize  stories;   
    @synthesize  item;
    @synthesize  currentElement; 
    @synthesize  currentTitle, currentDate, currentSummary, currentLink;


    // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
    /*
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization.
        }
        return self;
    }
    */

    #pragma mark -
    #pragma mark Parsing

    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
    - (void)viewDidLoad {
        [super viewDidLoad];
    }


    - (void)viewDidAppear:(BOOL)animated 
    { 
        [super viewDidAppear:animated]; 
        if ([stories count] == 0) { 
            NSString * path = @"http://icms7.bitmascot.com:8080/webcommander2.0S2/rest/services/catalogue/getAllDummyCategoryProduct"; 
            [self parseXMLFileAtURL:path]; 
        } 
        cellSize = CGSizeMake([newsTable bounds].size.width, 60); 
    }


    - (void)parseXMLFileAtURL:(NSString *)URL 
    { 
        stories = [[NSMutableArray alloc] init]; 
        //you must then convert the path to a proper NSURL or it won't work 
        NSURL *xmlURL = [NSURL URLWithString:URL]; 
        // here, for some reason you have to use NSClassFromString when trying to alloc NSXMLParser, otherwise you will get an object not found error 
        // this may be necessary only for the toolchain 
        rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL]; 
        // Set self as the delegate of the parser so that it will receive the parser delegate methods callbacks. 
        [rssParser setDelegate:self]; 
        // Depending on the XML document you're parsing, you may want to enable these features of NSXMLParser. 
        [rssParser setShouldProcessNamespaces:NO]; 
        [rssParser setShouldReportNamespacePrefixes:NO]; 
        [rssParser setShouldResolveExternalEntities:NO]; 
        [rssParser parse];
    }

    - (void)parserDidStartDocument:(NSXMLParser *)parser 
        { 
            NSLog(@"found file and started parsing"); 
        } 
    - (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError 
        { 
            NSString * errorString = [NSString stringWithFormat:@"Unable to download story feed from web site (Error code %i )", [parseError code]]; 
            NSLog(@"error parsing XML: %@", errorString); 
            UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
            [errorAlert show]; 
        } 
    - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{ 
        NSLog(@"found this element: %@", elementName); 
        currentElement = [elementName copy]; 
        if ([elementName isEqualToString:@"ProductData"]) 
        { 
            // clear out our story item caches... 
            item = [[NSMutableDictionary alloc] init]; 
            currentTitle = [[NSMutableString alloc] init]; 
            currentDate = [[NSMutableString alloc] init]; 
            currentSummary = [[NSMutableString alloc] init]; 
            currentLink = [[NSMutableString alloc] init]; 
        }
    } 
    - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{ 
        //NSLog(@"ended element: %@", elementName); 
        if ([elementName isEqualToString:@"ProductData"]) 
            { // save values to an item, then store that item into the array... 
                [item setObject:currentTitle forKey:@"id"]; 
                [item setObject:currentLink forKey:@"productNumber"]; 
                [item setObject:currentSummary forKey:@"name"]; 
                [item setObject:currentDate forKey:@"dateCreated"]; 
                [stories addObject:[item copy]];
                NSLog(@"adding story: %@", currentTitle); 
            } 
    } 
    - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{ 
        NSLog(@"found characters: %@", string); 
        // save the characters for the current item... 
        if ([currentElement isEqualToString:@"ProductData"]) 
            { 
                [currentTitle appendString:string]; 
            } 
        else if ([currentElement isEqualToString:@"id"]) 
            { 
                [currentLink appendString:string]; 
            } 
        else if ([currentElement isEqualToString:@"ProductNumber"]) 
        { 
            [currentSummary appendString:string]; 
        } 
        else if ([currentElement isEqualToString:@"dateCreatrd"]) 
        { 
            [currentDate appendString:string]; 
        } 
    } 
    - (void)parserDidEndDocument:(NSXMLParser *)parser { 
        [activityIndicator stopAnimating]; 
        [activityIndicator removeFromSuperview]; 
        NSLog(@"all done!"); 
        NSLog(@"stories array has %d items", [stories count]);
        NSLog(@"data in stories: %@",[stories description]);
        [newsTable reloadData]; 
    }


    #pragma mark tableView


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

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
    {
        return 1;
    }

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

        static NSString *MyIdentifier = @"MyIdentifier"; 
        UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:MyIdentifier]; 
        if (cell == nil) 
        { 

            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier: MyIdentifier];

        } 

        // Set up the cell 
        int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1]; 
        //[cell setText:[[stories objectAtIndex: storyIndex] objectForKey: @"title"]];
        //[cell setLabelText:[[stories objectAtIndex:storyIndex] objectForKey: @"ProductData"]];
        //[cell setText:[stories objectAtIndex:storyIndex]];
        cell.textLabel.text = [stories objectAtIndex:storyIndex];
        NSLog(@"%@ ",cell.textLabel.text);

        //cell.detailTextLabel.text = [stories objectAtIndex:indexPath.row];

        return cell; 
    }


    /*
    - (void)setLabelText:(NSString *)_text{
        UILabel *cellText;
        cellText.text= _text;
        [cellText sizeToFit];
    }
    */
    /*
    // Override to allow orientations other than the default portrait orientation.
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        // Return YES for supported orientations.
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    */

    - (void)didReceiveMemoryWarning {
        // Releases the view if it doesn't have a superview.
        [super didReceiveMemoryWarning];

        // Release any cached data, images, etc. that aren't in use.
    }

    - (void)viewDidUnload {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }


    - (void)dealloc { 
            [currentElement release]; 
            [rssParser release]; 
            [stories release];
            [item release]; 
            [currentTitle release];
            [currentDate release]; 
            [currentSummary release]; 
            [currentLink release]; 
            [super dealloc]; 
        }


    @end

    
  • 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-26T02:17:12+00:00Added an answer on May 26, 2026 at 2:17 am

    Try to set value of property textLabel, not detailedTextLabel :

    cell.textLabel.text = [[stories objectAtIndex:storyIndex] valueForKey:@"productNumber"];
    

    Also try to create cell using predefined styles:

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier: MyIdentifier];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am POSTING some data from an IPhone application want want to be able
i am newer to iphone application development so please anybody help me.my main problem
I want to ask about the iPhone application and objective C question. In the
I am getting started with iPhone application development and would like to create an
This is my first iPhone application and it's based on a top-level tableview. Selections
I'm writing an iPhone application that uses GPS data. My problem is that the
I'm working on an iphone application (not web app) and I'd like to build
To be clear, this is for a normal iPhone application, and not a game.
I am going to attempt to teach some iphone application development at my job,
Just starting up with iPhone development. I'm not sure why this code works. I've

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.