Last active
August 22, 2018 16:51
-
-
Save khanlou/85278cd2014969aff62218f22047abe3 to your computer and use it in GitHub Desktop.
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
@interface HTTPMethod: NSString | |
+ (HTTPMethod *)GET; | |
+ (HTTPMethod *)POST; | |
@end |
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
@interface HTTPMethod() | |
@property NSString *name; | |
@end | |
@implementation HTTPMethod | |
+ (HTTPMethod *)GET { | |
return [[HTTPMethod alloc] initWithName:@"GET"]; | |
} | |
+ (HTTPMethod *)POST { | |
return [[HTTPMethod alloc] initWithName:@"POST"]; | |
} | |
- (instancetype)initWithName:(NSString *)name { | |
self = [super init]; | |
if (!self) return nil; | |
_name = name; | |
return self; | |
} | |
- (NSUInteger)length { | |
return self.name.length; | |
} | |
- (unichar)characterAtIndex:(NSUInteger)index { | |
return [self.name characterAtIndex:index]; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment