Is this the correct way to reloadData on a UITableView?

Posted by Sheehan Alam on Stack Overflow See other posts from Stack Overflow or by Sheehan Alam
Published on 2010-06-04T20:04:04Z Indexed on 2010/06/06 12:22 UTC
Read the original article Hit count: 193

I am trying to append objects to my data source and then reload the table. Is this the correct way of approaching it?

self.items is my datasource

//Copy current items
        self.itemsCopy = [self.items mutableCopy];//[[NSMutableArray alloc] initWithArray:self.items copyItems:NO];

        NSLog(@"Copy Size before append: %d",[itemsCopy count]);

        //Get new items
        int lastMsgID = [self getLastMessageID];
        [self.coreData getMoreMessages:self.title lastID:lastMsgID]; //This will update self.items with 30 objects

        //Append new items
        [itemsCopy addObjectsFromArray:self.items];

        //Empty items and copy itemsCopy
        [self.items removeAllObjects];
        self.items = [self.itemsCopy mutableCopy];

        NSLog(@"Actual Size after append: %d",[self.items count]);

        //Reload data
        [tableView reloadData];

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c