Skip to content

Instantly share code, notes, and snippets.

@hborders
Last active March 13, 2017 16:44
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/094f05d932b3d7a1e389184ba525b0c3 to your computer and use it in GitHub Desktop.
Save hborders/094f05d932b3d7a1e389184ba525b0c3 to your computer and use it in GitHub Desktop.
An Objective-C pattern for making sum types - ExampleFoo.h
#import "Example.h" // https://gist.github.com/hborders/2af9b39e27b62ef9e68c65085126fe4a
@interface ExampleFoo : Example
@property (nonatomic, readonly) NSString * _Nonnull f;
@property (nonatomic, readonly) NSString * _Nonnull g;
+ (instancetype _Nonnull)new NS_UNAVAILABLE;
- (instancetype _Nonnull)init NS_UNAVAILABLE;
- (instancetype _Nonnull)initWithF:(NSString * _Nonnull)f
g:(NSString * _Nonnull)g NS_DESIGNATED_INITIALIZER;
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment