Skip to content

Instantly share code, notes, and snippets.

@talkol
Last active June 12, 2016 00:34
Show Gist options
  • Save talkol/ffe1086dd58711477bf5685e9e10232b to your computer and use it in GitHub Desktop.
Save talkol/ffe1086dd58711477bf5685e9e10232b to your computer and use it in GitHub Desktop.
// this is finally the full implementation of this function, all missing pieces filled in
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"CustomCell";
TableViewCell *cell = (TableViewCell *)[theTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.cellView = [self getUnusedCell];
NSLog(@"Allocated childIndex %d for row %d", (int)cell.cellView.tag, (int)indexPath.row);
} else {
NSLog(@"Recycled childIndex %d for row %d", (int)cell.cellView.tag, (int)indexPath.row);
}
// we're communicating back by dispatching an event to JS
NSDictionary *event = @{
@"target": cell.cellView.reactTag,
@"childIndex": @(cell.cellView.tag),
@"rowID": @(indexPath.row),
@"sectionID": @(indexPath.section),
};
[_eventDispatcher sendInputEventWithName:@"onChange" body:event];
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment