UITableView: NSMutableArray not appearing in table

Posted by Michael Orcutt on Stack Overflow See other posts from Stack Overflow or by Michael Orcutt
Published on 2010-04-07T00:42:44Z Indexed on 2010/04/07 2:33 UTC
Read the original article Hit count: 260

Filed under:
|

I'm new to objective c and iPhone programming. I can't seem to figure out why no cells will fill when I run this code. The xml content displays in the console log and xcode displays no errors. Can any help?

    - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
    if(![elementName compare:@"Goal"] )
    {
        tempElement = [[xmlGoal alloc] init];
    }
    else if(![elementName compare:@"Title"])
    {
        currentAttribute = [NSMutableString string];
    }
    else if(![elementName compare:@"Progress"]) 
    {
        currentAttribute = [NSMutableString string];
    }

}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    if(![elementName compare:@"Goal"]) 
    {
        [xmlElementObjects addObject:tempElement];

    }
    else if(![elementName compare:@"Title"]) 
    {
        NSLog(@"The Title of this event is %@", currentAttribute);
        [tempElement setTitled:currentAttribute];
     }
     else if(![elementName compare:@"Progress"]) 
    {
        NSLog(@"The Progress of this event is %@", currentAttribute);
        [tempElement setProgressed:currentAttribute];
    }

}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    if(self.currentAttribute)
    {
        [self.currentAttribute appendString:string];
    }
}

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

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

    static NSString *CellIdentifier = @"Cell";

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

    // Set up the cell...
    cell.textLabel.text = [xmlElementObjects objectAtIndex:indexPath.row];

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {   

}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about app