Composite Components

Avoid subclassing CKComponent directly. Instead, subclass CKCompositeComponent.

A "composite component" simply wraps another component, hiding its implementation details from the outside world.

For example, imagine you're implementing a button to share an article in a newsreader app. You could implement ShareButtonComponent as a composite component that wraps a CKButtonComponent:

@implementation ShareButtonComponent
+ (instancetype)newWithArticle:(ArticleModel *)article
{
return [super newWithComponent:
CK::ButtonComponentBuilder()
.action(@selector(shareTapped))
.build()];
}
- (void)shareTapped
{
// Share the article
}
@end

Never Subclass Components contains more information about why you should favor subclassing CKCompositeComponent whenever possible.