CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

ProtocolInjection 1.0.3

ProtocolInjection 1.0.3

Maintained by GodL.



ProtocolInjection

License MIT  CocoaPods  Support 

Default implementation of protocol optional methods

Usage

Create protocol

@protocol Runnable <NSObject>

@injection

+ (Class)runClass;

- (BOOL)canRun;

@end

Realize the methods

@injectprotocol(Runnable)

+ (Class)runClass {
    return self;
}

- (BOOL)canRun {
    return YES;
}

@end

Confirm this protocol

@interface ViewController ()<Runnable>

@end

Realize injection in .m

@implementation ViewController (Injection)

injectionable

@end

Result

ProtocolInjection[10762:501490] 1   ViewController

Installation

CocoaPods

  1. Add pod 'ProtocolInjection' to your Podfile.
  2. Run pod install or pod update.
  3. Import <ProtocolInjection/ProtocolInjection.h>.

Requirements

This library requires iOS 6.0+ and Xcode 8.0+.

License

ProtocolInjection is provided under the MIT license. See LICENSE file for details.