Skip to content

Instantly share code, notes, and snippets.

@khanlou
Last active August 22, 2018 16:51
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 khanlou/85278cd2014969aff62218f22047abe3 to your computer and use it in GitHub Desktop.
Save khanlou/85278cd2014969aff62218f22047abe3 to your computer and use it in GitHub Desktop.
@interface HTTPMethod: NSString
+ (HTTPMethod *)GET;
+ (HTTPMethod *)POST;
@end
@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