To run the example project, clone the repo, and run pod install
from the Example directory first.
Declare a module.
@module(MyModule)
-(void)hello;
@end
Implement module methods in a .m
file.
@module_implementation(MyModule)
-(void)hello
{
NSLog(@"Hello, world!");
}
@end
Declare an interface.
@interface Foo : NSObject<MyModule>
-(void)foo;
@end
Implement Foo's method and mixin it with MyModule
in a .m
file.
@mixin(Foo, MyModule)
@implementation Foo
-(void)foo
{
NSLog(@"Foo");
}
@end
Use Foo
to call methods in MyModule
.
Foo *f = [[Foo alloc] init];
[f hello];
ObjCMixin is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ObjCMixin"
Huan Du, [email protected]
ObjCMixin is available under the MIT license. See the LICENSE file for more info.