TableView Cell for 3 different articles

Discussion in 'iOS Programming' started by newtoiphonesdk, May 22, 2012.

  1. newtoiphonesdk macrumors 6502a

    Jul 30, 2010
    I want to create a custom cell for a TableView that will contain 3 UIImageViews, loading a different picture in each from separate entries in an XML file. I know that I can create a custom cell for the TableView, but am not sure where to go from there. How to set the number of rows based off number of entries in the XML, and how to set each of the 3 UIImageViews in the custom cell to load a different Image, and have those each behave differently when selected, instead of one action for the entire row.

  2. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    depends how your XML Data is structures, you have several ways.. You can create objects from your XML Structure, and give the properties to the above said "Custom Cell", or you just have 1 big array, you clip a piece of array out of it, for each "row", and just set those 3 elements from the array as properties onto your "Custom Cell" :/
    It's not "that" easy if you are kinda new ^_-
  3. newtoiphonesdk thread starter macrumors 6502a

    Jul 30, 2010
    -(void)viewDidLoad {
     self.allEntries = [NSMutableArray array];
        self.queue = [[[NSOperationQueue alloc] init] autorelease];
        self.feeds = [NSArray arrayWithObjects:@"", 
        [self refresh];    
    - (void)refresh {
        for (NSString *feed in _feeds) {
            NSURL *url = [NSURL URLWithString:feed];
            ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
            [request setDelegate:self];
            [_queue addOperation:request];
    Then when I parse I set this up:
    - (void)parseRss:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {
        NSArray *channels = [rootElement elementsForName:@"channel"];
        for (GDataXMLElement *channel in channels) {            
            NSString *blogTitle = [channel valueForChild:@"title"];                    
            NSArray *items = [channel elementsForName:@"item"];
            for (GDataXMLElement *item in items) {
                NSString *articleTitle = [item valueForChild:@"title"];
                NSString *articleUrl = [item valueForChild:@"guid"];            
                NSString *articleDateString = [item valueForChild:@"pubDate"];   
                NSString *articleImage = [item valueForChild:@"image"];
                NSDate *articleDate = [NSDate dateFromInternetDateTimeString:articleDateString formatHint:DateFormatHintRFC822];
                RSSEntrySermons *entry = [[[RSSEntrySermons alloc] initWithBlogTitle:blogTitle articleTitle:articleTitle articleUrl:articleUrl articleDate:articleDate articleImage:articleImage] autorelease];
                [entries addObject:entry];
    I use a tutorial and GDATAXML library to parse it and currently on my cellForRowAtIndexPath, I have:
        RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
    NSString *pictureURLwithstring = entry.articleImage;
    Where RSSEntry is a class that was used in the tutorial for parsing the different elements.

    Would I be able to simply parse it in a Custom Cell created? Not sure how to get it in 3 images per cell, so that from left to right it would be:
    entry.articleImage(first picture) entry.articleImage(from 2nd pic) entry.aritcleImage(from 3rd pic)

Share This Page