TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
Implement updateContent:
- (void)updateContent
{
self.makeLabel.text = self.make;
self.modelLabel.text = self.model;
self.colorNameLabel.text = self.colorName;
self.descriptionLabel.text = self.carDescription;
[self setNeedsLayout];
}
Implement keyPathsTriggerUpdate:
+ (NSArray *)keyPathsToTriggerUpdate
{
return @[@"make", @"colorName", @"model", @"carDescription"];
}
That's it. When one of the keypaths changes, setNeedsUpdate is automatically called.
If you are not a UIView or UIViewController, you must call startObservingForUpdates on yourself to add the observers during initialization.
See demo in https://github.com/hoteltonight/HTKit
HTCarDetailsViewV1, V2 and V3 show incremental improvements to a simple dynamic UI component using these tools.
This sequence of improvements was discussed at NSMeetup April 2013, slides here: http://d.pr/f/jczG
The recommended installation method is cocoapods. Add this line to your Podfile:
pod 'HTGraphics'
SFObservers is a dependency for those who don't cocoapods.
SFObservers is a dependecy, used to automatically remove KVO observers.
Tweet the authors @jakejennings and @jonsibs, and check out HotelTonight's engineering blog: http://engineering.hoteltonight.com
Also, check out HotelTonight's other iOS open source: