HTUpdateAggregator 1.0.1

HTUpdateAggregator 1.0.1

LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.

  • By
  • Jacob Jennings and Jon Sibley

HTUpdateAggregator improves update logic in NSObject/UIView/UIViewController subclasses

  • Familiar pattern of updateContent, setNeedsUpdate, and updateIfNeeded
    • Just like layoutSubviews, setNeedsLayout, and layoutIfNeeded
  • Automatically trigger updates using key-value observation of properties
    • Avoids overriding setters, potentially breaking synthesized behaviors and adding boilerplate
  • Aggregate update calls within runloops
  • Centralized updateContent improves maintainability for most cases


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

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:


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.

Contributions welcome!

Use it? Love/hate it?

Tweet the authors @jakejennings and @jonsibs, and check out HotelTonight's engineering blog:

Also, check out HotelTonight's other iOS open source: