Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <Foundation/Foundation.h>
- @interface TestCls: NSObject
- @property(nonatomic, copy) NSString *name;
- @end
- @implementation TestCls
- - (instancetype)init {
- if (self = [super init]) {
- [self testFunction];
- }
- return self;
- }
- - (void)testFunction {
- NSLog(@"testFunction %@", self.name);
- }
- @end
- @interface TestCls (TestCategory)
- - (void)testFunction;
- @end
- @implementation TestCls (TestCategory)
- - (void)testFunction {
- NSLog(@"another testFunction");
- }
- - (Class)class {
- return [NSString class];
- }
- @end
- int main() {
- TestCls *testCls = [[TestCls alloc] init];
- [testCls testFunction];
- NSLog(@"which class is testCls %@", [testCls class]);
- NSString *testStr = @"testStr";
- NSLog(@"which class is testStr %@", [testStr class]);
- }
- @implementation NSString (Test_Category)
- - (Class)class {
- return [NSNumber class];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement