Skip to content

Instantly share code, notes, and snippets.

@bunnyhero
Last active February 19, 2022 02:04
Show Gist options
  • Save bunnyhero/9988574 to your computer and use it in GitHub Desktop.
Save bunnyhero/9988574 to your computer and use it in GitHub Desktop.
Example of Reactive Cocoa binding for a reusable cell.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:REUSABLE_CELL_ID];
UILabel *label = (UILabel *)[cell viewWithTag:VIEW_TAG];
Model *someModel = [self getModelFromIndexPath:indexPath];
// `takeUntil:` makes the RACObserve() signal complete (and thus breaks the subscription)
// when the cell is recycled.
RAC(label, text) = [RACObserve(someModel, someKey)
takeUntil:cell.rac_prepareForReuseSignal];
return cell;
}
@tunidev
Copy link

tunidev commented Aug 2, 2016

@CharlesW95 did you find a solution please ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment