Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/forkingdog/ProtocolKit
Protocol extension for Objective-C
https://github.com/forkingdog/ProtocolKit
Last synced: 1 day ago
JSON representation
Protocol extension for Objective-C
- Host: GitHub
- URL: https://github.com/forkingdog/ProtocolKit
- Owner: forkingdog
- License: mit
- Created: 2015-09-02T03:44:06.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-03-11T03:33:05.000Z (over 5 years ago)
- Last Synced: 2024-08-01T19:56:30.139Z (3 months ago)
- Language: Objective-C
- Size: 113 KB
- Stars: 573
- Watchers: 25
- Forks: 81
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-iOS - ProtocolKit - Protocol extension for Objective-C (Foundation)
README
# ProtocolKit
Protocol extension for Objective-C# Usage
Your protocol:
``` objc
@protocol Forkable
@optional
- (void)fork;@required
- (NSString *)github;@end
```Protocol extension, add default implementation, use `@defs` magic keyword
``` objc
@defs(Forkable)
- (void)fork {
NSLog(@"Forkable protocol extension: I'm forking (%@).", self.github);
}- (NSString *)github {
return @"This is a required method, concrete class must override me.";
}@end
```Your concrete class
``` objc
@interface Forkingdog : NSObject
@end@implementation Forkingdog
- (NSString *)github {
return @"https://github.com/forkingdog";
}@end
```Run test
``` objc
[[Forkingdog new] fork];
```Result
```
[Console] Forkable protocol extension: I'm forking (https://github.com/forkingdog).
```