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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:07:28+00:00 2026-05-14T04:07:28+00:00

I have a problem with data in UITableView. I have UIViewController, that contains UITableView

  • 0

I have a problem with data in UITableView. I have UIViewController, that contains UITableView outlet and few more things I am using and … It works 🙂 … it works lovely, but …

I’ve created an RSS reader class that is using delegates to deploy the data to the table … and once again, If I’ll just create dummy data in the main controller everything works!

problem is with this line: rss.delegate = self;

Preview looks a little bit broken than here are those RSS reader files on Google code:

(Link to the header file on GoogleCode)

(Link to the implementation file on Google code)

viewDidLoad function of my controller:

IGDataRss20 *rss = [[[IGDataRss20 alloc] init] autorelease];
rss.delegate = self;
[rss initWithContentsOfUrl:@"http://rss.cnn.com/rss/cnn_topstories.rss"];

and my delegate methods:

- (void)parsingEnded:(NSArray *)result {
    super.data = [[NSMutableArray alloc] initWithArray:result];
    NSLog(@"My Items: %d", [super.data count]);
    [super.table reloadData];
    NSLog(@"Parsing ended");
}

- (void)parsingError:(NSString *)message {
    NSLog(@"MyMessage: %@", message);
}

- (void)parsingStarted:(NSXMLParser *)parser {
    NSLog(@"Parsing started");
}

Just to clarify, NSLog(@”Parsing ended”); is being executed and I have 10 items in the array.

Hope someone will be able to help me as I am becoming to be quite desperate, and I thought I am not already such a greenhorn 🙂

Thanks,

Ondrej

Full copy of my header file (table controller)

the WGTempTableController class is UIViewController with table outlet, data array etc …

//
//  CRFeedController.h
//  czReader
//
//  Created by Ondrej Rafaj on 5.4.10.
//  Copyright 2010 Home. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "WGTempTableController.h"
#import <IGDataRss20.h>


@interface CRFeedController : WGTempTableController <IGDataRss20Delegate> {

    //NSString *startUrl;

}

@end

Full copy of my implementation file (table controller)

All other functions like numberOfSectionsInTableView or numberOfRowsInSection are in that WGTempTableController

//
//  CRFeedController.m
//  czReader
//
//  Created by Ondrej Rafaj on 5.4.10.
//  Copyright 2010 Home. All rights reserved.
//

#import "CRFeedController.h"
#import "WGTempCell.h"


@implementation CRFeedController

- (void)viewDidLoad {
    [super viewDidLoad];
    IGDataRss20 *rss = [[[IGDataRss20 alloc] init] autorelease];
    rss.delegate = self;
    [rss initWithContentsOfUrl:@"http://rss.cnn.com/rss/cnn_topstories.rss"];
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)parsingEnded:(NSArray *)result {
    super.data = [[NSMutableArray alloc] initWithArray:result];
    NSLog(@"My Items: %d", [super.data count]);
    [super.table reloadData];
    NSLog(@"Parsing ended");
}

- (void)parsingError:(NSString *)message {
    NSLog(@"MyMessage: %@", message);
}

- (void)parsingStarted:(NSXMLParser *)parser {
    NSLog(@"Parsing started");
}

- (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;
}

#pragma mark Table view

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"MyCell";
    WGTempCell *cell = (WGTempCell *) [table dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CRFeedCell" owner:nil options:nil];
        for(id currentObject in topLevelObjects) {
            if([currentObject isKindOfClass:[WGTempCell class]]) {
                cell = (WGTempCell *) currentObject;
                break;
            }
        }
    }
    NSDictionary *d = [super.data objectAtIndex:indexPath.row];
    [[cell cellTitle] setText:[d objectForKey:@"title"]];
    return cell;
}



- (void)dealloc {
    [super dealloc];
}


@end

Full copy of my header file (rss reader)

//
//  IGDataRss20.h
//  IGFrameworkProject
//
//  Created by Ondrej Rafaj on 4.4.10.
//  Copyright 2010 Home. All rights reserved.
//

#import <Foundation/Foundation.h>

@class IGDataRss20;

@protocol IGDataRss20Delegate <NSObject>

@optional

- (void)parsingStarted:(NSXMLParser *)parser;

- (void)parsingError:(NSString *)message;

- (void)parsingEnded:(NSArray *)result;

@end


@interface IGDataRss20 : NSObject {

    NSXMLParser *rssParser;
    NSMutableArray *data;

    NSMutableDictionary *currentItem;

    NSString *currentElement;

    id <IGDataRss20Delegate> delegate;

}

@property (nonatomic, retain) NSMutableArray *data;

@property (nonatomic, assign) id <IGDataRss20Delegate> delegate;


- (void)initWithContentsOfUrl:(NSString *)rssUrl;

- (void)initWithContentsOfData:(NSData *)inputData;


@end

Full copy of my implementation file (rss reader)

//
//  IGDataRss20.m
//  IGFrameworkProject
//
//  Created by Ondrej Rafaj on 4.4.10.
//  Copyright 2010 Home. All rights reserved.
//

#import "IGDataRss20.h"


@implementation IGDataRss20

@synthesize data, delegate;

- (void)initWithContentsOfUrl:(NSString *)rssUrl {
    self.data = [[NSMutableArray alloc] init];
    NSURL *xmlURL = [NSURL URLWithString:rssUrl];
    rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
    [rssParser setDelegate:self];
    [rssParser setShouldProcessNamespaces:NO];
    [rssParser setShouldReportNamespacePrefixes:NO];
    [rssParser setShouldResolveExternalEntities:NO];
    [rssParser parse];
}

- (void)initWithContentsOfData:(NSData *)inputData {
    self.data = [[NSMutableArray alloc] init];
    rssParser = [[NSXMLParser alloc] initWithData:inputData];
    [rssParser setDelegate:self];
    [rssParser setShouldProcessNamespaces:NO];
    [rssParser setShouldReportNamespacePrefixes:NO];
    [rssParser setShouldResolveExternalEntities:NO];
    [rssParser parse];
}

- (void)parserDidStartDocument:(NSXMLParser *)parser {
    [[self delegate] parsingStarted:parser];
}

- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
    NSString * errorString = [NSString stringWithFormat:@"Unable to parse RSS feed (Error code %i )", [parseError code]];
    NSLog(@"Error parsing XML: %@", errorString);
    if ([parseError code] == 31) NSLog(@"Error code 31 is usually caused by encoding problem.");
    [[self delegate] parsingError:errorString];
}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
    currentElement = [elementName copy];
    if ([elementName isEqualToString:@"item"]) currentItem = [[NSMutableDictionary alloc] init];
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
    if ([elementName isEqualToString:@"item"]) {
        [data addObject:(NSDictionary *)[currentItem copy]];
    }
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
    if (![currentItem objectForKey:currentElement]) [currentItem setObject:[[[NSMutableString alloc] init] autorelease] forKey:currentElement];
    [[currentItem objectForKey:currentElement] appendString:string];
}

- (void)parserDidEndDocument:(NSXMLParser *)parser {
    //NSLog(@"RSS array has %d items: %@", [data count], data);
    [[self delegate] parsingEnded:(NSArray *)self.data];
}




- (void)dealloc {
    [data, delegate 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-14T04:07:28+00:00Added an answer on May 14, 2026 at 4:07 am

    Your subject says it crashes when you try to scroll. I don’t know what this would have to do with your rss.delegate, so I’m just going to ignore that and focus on probable scrolling-related bugs here, which are usually in tableView:cellForRowAtIndexPath:.

    1. Check your CRFeedCell.xib, view info on your WGTempCell object, and make sure its Identifier field matches your CellIdentifier in your code. (“MyCell”)

    2. Make sure you’re not using that same CellIdentifier for some other UITableViewCell subclass elsewhere in your code.

    3. What kind of crash is it? If it’s EXC_BAD_ACCESS, double-click on your executable, go to Arguments, create an NSZombieEnabled environment variable, and set it to YES. (Uncheck it when you’re done debugging to avoid leaking memory.) This will show you which object you were trying to access when the app crashed.

    4. Set a breakpoint on the setText: call in tableView:cellForRowAtIndexPath:. Then at your gdb prompt, type po [d objectForKey:@”title”]. Make sure that object is really an NSString.

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

Sidebar

Ask A Question

Stats

  • Questions 377k
  • Answers 377k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I created your models and tables in my local setup.… May 14, 2026 at 8:45 pm
  • Editorial Team
    Editorial Team added an answer I can reproduce the error message this way: import cPickle… May 14, 2026 at 8:45 pm
  • Editorial Team
    Editorial Team added an answer What it's saying is that you have the same background… May 14, 2026 at 8:45 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.