Skip to content

Instantly share code, notes, and snippets.

@hborders
Last active March 13, 2017 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hborders/c58b26ee0acb30c9a8bc74a5fd591284 to your computer and use it in GitHub Desktop.
Save hborders/c58b26ee0acb30c9a8bc74a5fd591284 to your computer and use it in GitHub Desktop.
An Objective-C pattern for making sum types - Example.m
#import "ExamplePrivate.h" // https://gist.github.com/hborders/12fcbe34cf4de68c2317bad92a8e223d
@implementation Example
- (instancetype _Nonnull)initPrivate {
return [super init];
}
- (void)switchFoo:(void (^ _Nonnull)(ExampleFoo * _Nonnull foo_))fooBlock
bar:(void (^ _Nonnull)(ExampleBar * _Nonnull bar_))barBlock {
// Subclasses must implement and call
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment