(Activity *activity in activities) { ActivityCell *activityCell = [self transformActivityCell:activity]; if (activityCell.shouldDisplay) { [activityCells addObject:activityCell]; } } Intent: Transform activities to activity cells removing those that should not be displayed.
= [NSMutableArray new]; for (NSUInteger i = 0; i < activities.count; ++i) { [indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]]; } Intent: Get NSIndexPaths in section 0 from row 0 up to activities.count
action:@selector(saveButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; self.saveButton.selected = doc.isSaved; self.doc = doc; } ! - (void)saveButtonPressed:(id)sender { [self renderSaveView:!self.saveButton.selected]; self.doc.isSaved = !self.doc.isSaved [API saveDoc:self.doc onComplete:^(BOOL success) { if (!success) { [self renderSaveView:!self.saveButton.selected]; self.doc.isSaved = !self.doc.isSaved } }]; // Q: how do you propagate the change to all local instances of the doc }
action:@selector(saveButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; self.saveButton.selected = doc.isSaved; self.doc = doc; } ! - (void)saveButtonPressed:(id)sender { [self renderSaveView:!self.doc.isSaved]; self.doc.isSaved = !self.doc.isSaved [API saveDoc:self.doc onComplete:^(BOOL success) { if (!success) { [self renderSaveView:!self.doc.isSaved]; self.doc.isSaved = !self.doc.isSaved; } }]; // Q: how do you propagate the change to all local instances of the doc } View logic duplication Communicating through ivar