ProtocolInjection 1.0.3

ProtocolInjection 1.0.3

GodL 维护。



ProtocolInjection

License MIT  CocoaPods  支持 

协议可选方法的后台实现

用法

创建协议

@protocol Runnable <NSObject>

@injection

+ (Class)runClass;

- (BOOL)canRun;

@end

实现方法

@injectprotocol(Runnable)

+ (Class)runClass {
    return self;
}

- (BOOL)canRun {
    return YES;
}

@end

确认此协议

@interface ViewController ()<Runnable>

@end

在 .m 中实现注入

@implementation ViewController (Injection)

injectionable

@end

结果

ProtocolInjection[10762:501490] 1   ViewController

安装

CocoaPods

  1. pod 'ProtocolInjection' 添加到您的 Podfile。
  2. 运行 pod installpod update
  3. 导入 <ProtocolInjection/ProtocolInjection.h>。

需求

此库需要iOS 6.0+和Xcode 8.0+。

许可证

ProtocolInjection遵循MIT许可证。请参阅LICENSE文件以了解详细信息。