Question

I'm going to paste the code below, then tell you what I've tried to determine from the code.

If you're reading this quickly, start with the text right above the next code-block.

- (void)tableViewDidLoadModel:(UITableView*)tableView {
self.items = [NSMutableArray array];
self.sections = [NSMutableArray array];

NSMutableDictionary *groups = [NSMutableDictionary dictionary];

for (int c = 0;c < [_contacts.people count];c++) {
    NSDictionary *person = [_contacts.people objectAtIndex:c];
    NSString *name = [person objectForKey:@"fullName"];
    NSString *letter = [name substringToIndex:1];
    NSMutableArray *section = [groups objectForKey:letter];
    NSLog(@"%@ - %@ - %@", name, [person objectForKey:@"index"], [person objectForKey:@"abId"]);
    if (!section) {
        section = [NSMutableArray array];
        [groups setObject:section forKey:letter];
    }

    TTTableItem *item = [ttItem itemWithText:name URL:[person objectForKey:@"index"]];
    [section addObject:item];
}

Someone else wrote this block of code. From what I can determine, they're trying to take the user's contacts and fill a TableView.

Now my real question has to do with that last line:

TTTableItem *item = [ttItem itemWithText:name URL:[person objectForKey:@"index"]];
    [section addObject:item];

This is using the Three20 framework. Apparently what the previous developer did was use TTTableItem to kind of get a pre-formatted UITableViewCell. (Hopefully I'm thinking right?) I need to replace this line of code with something normal. I've thought of just using UITableViewCell, but other than that I'm not really sure how to start?

Was it helpful?

Solution

-tableViewDidLoadModel: is a method that comes from the TTTableViewDataSource protocol, so if you're trying to remove Three20 from your project, you've got more to do than just replace the TTTableItem.

TTTableItem is a subclass of NSObject, and the only thing it seems to add is a userInfo property. To get rid of it, you could start by creating your own class with the same property.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top