// // BlockBasedSelector.m // // Created by Charlton Provatas on 11/2/17. // Copyright © 2017 CharltonProvatas. All rights reserved. // #import "BlockBasedSelector.h" #import @implementation BlockBasedSelector @end void class_addMethodWithBlock(Class class, SEL newSelector, OBJCBlock block) { IMP newImplementation = imp_implementationWithBlock(block); Method method = class_getInstanceMethod(class, newSelector); class_addMethod(class, newSelector, newImplementation, method_getTypeEncoding(method)); } void class_addMethodWithBlockAndSender(Class class, SEL newSelector, OBJCBlockWithSender block) { IMP newImplementation = imp_implementationWithBlock(block); Method method = class_getInstanceMethod(class, newSelector); class_addMethod(class, newSelector, newImplementation, method_getTypeEncoding(method)); }