[go: up one dir, main page]

Skip to content

h386926074/myself

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 

Repository files navigation

runtime 学习小代码

//大神不要见笑 有问题请指点一二

#import <Foundation/Foundation.h> #import <objc/runtime.h>

@interface MyClass : NSObject

@end

@implementation MyClass

@end

void myMethodIMP(id self,SEL _cmd){ NSLog(@"runtime hello"); }

int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... NSLog(@"Hello, World!");

    NSLog(@"%s",@selector(test));
    NSLog(@"%lu",strlen(@selector(test)));
    
    char *s = calloc(100, sizeof(char));
    strcat(s,@selector(test));
    strcat(s,@selector(test));
    NSLog(@"%s",s);
    free(s);
    
    class_addMethod([MyClass class], @selector(myMethod), (IMP)myMethodIMP, "v@:");
    MyClass *myObject = [[MyClass alloc] init];
    
    [myObject performSelector:@selector(myMethod)];

    
}
return 0;

}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published