Created
January 16, 2019 13:22
-
-
Save onurhuseyincantay/a6c5161285d00f35a6dc165066cbd93a to your computer and use it in GitHub Desktop.
Class Cluster Pattern implementation example
This file contains hidden or 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
typedef NS_ENUM (NSUInteger,PostType){ | |
PostTypeVideo, | |
PostTypePhoto, | |
PostTypePlain, | |
}; | |
@interface Post:NSObject | |
@property (copy) NSString *title; | |
@property NSDate *createdDate; | |
// helper for creating Post Object | |
+ (Post*) postWithType:(PostType)type; | |
- (void) animatePost; | |
@end | |
@implementation Post | |
+(Post*)postWithType:(PostType)type{ | |
switch(type){ | |
case PostTypeVideo : | |
return [PostVideo new]; | |
break; | |
case PostTypePhoto : | |
return [PostPhoto new]; | |
break; | |
case PostTypePlain: | |
return [PostPlain new]; | |
break; | |
} | |
} | |
-(void) animatePost{ | |
// Subclasses implements this | |
} | |
@end | |
@interface PostVideo : Post | |
@end | |
@implementation PostVideo | |
- (void)animatePost{ | |
NSLog(“This is an video Animation Code!!!!") | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment