Skip to content

Commit

Permalink
Weakified self in README example to avoid retain cycles.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Amaral committed Feb 2, 2015
1 parent 3b3b85b commit f4aa176
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,22 @@ Here is a simple example of a table view with three section, two that are pre-bu
```objective-c
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];


__weak typeof(self) weakSelf = self;
OrganicCell *helloWorldCell = [OrganicCell cellWithStyle:UITableViewCellStyleDefault height:40 actionBlock:^{
[self doA];
[weakSelf doA];
}];
helloWorldCell.textLabel.text = @"Say Hello";

OrganicCell *goodbyeWorldCell = [OrganicCell cellWithStyle:UITableViewCellStyleDefault height:55 actionBlock:^{
[self doB];
[weakSelf doB];
}];
goodbyeWorldCell.textLabel.text = @"Say Goodbye";

OrganicSection *firstStaticSection = [OrganicSection sectionWithHeaderTitle:@"Welcome" cells:@[helloWorldCell, goodbyeWorldCell]];

OrganicCell *randomCell = [OrganicCell cellWithStyle:UITableViewCellStyleSubtitle height:44 actionBlock:^{
[self doC];
[weakSelf doC];
}];
randomCell.textLabel.text = @"Knock knock...";
randomCell.detailTextLabel.text = @"Who's there?";
Expand All @@ -124,7 +125,7 @@ Here is a simple example of a table view with three section, two that are pre-bu
return cell;
} actionBlock:^(NSInteger row) {
[self doDForRow:row];
[weakSelf doDForRow:row];
}];

self.sections = @[firstStaticSection, secondStaticSection, sectionWithReuse];
Expand Down

0 comments on commit f4aa176

Please sign in to comment.