Created
June 24, 2014 09:32
-
-
Save konrad1977/93da1aa745d1f17dc5f4 to your computer and use it in GitHub Desktop.
Simple example of using Builder pattern in Objective-C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//header file | |
typedef void (^ColorThemeBuilder)(id<ColorThemeProtocol> colorTheme); | |
@interface ThemeBuilder : NSObject <ColorThemeProtocol> | |
- (instancetype)initColorTheme:(ColorThemeBuilder)builder; | |
@end | |
//Implementation | |
@implementation ThemeBuilder | |
@synthesize backgroundColor; | |
@synthesize textColor; | |
@synthesize hudTextColor; | |
@synthesize hudBackgroundColor; | |
@synthesize tintColor; | |
@synthesize title; | |
@synthesize details; | |
- (instancetype)initColorTheme:(ColorThemeBuilder)builder { | |
self = [super init]; | |
if (self) { | |
builder(self); | |
} | |
return self; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment