runtime框架 Aspects 类方法使用

// NSString* nameClass = NSStringFromClass(MBProgressHUD.class);
// Class catMetal = objc_getMetaClass([nameClass UTF8String]);
// [catMetal aspect_hookSelector:@selector(showHUDAddedTo:animated:) withOptions:AspectPositionInstead usingBlock:^(id aspectInfo,UIView *view,BOOL bo){
// NSLog(@"%@ 对象的viewDidLoad调用了",aspectInfo.instance);
//
//
// int64_t delayInSeconds = 1.0;
//
// // 延迟的时间
// // 调用方法原来的实现.
//
// MBProgressHUD *processTouches;
// NSInvocation *invocation = aspectInfo.originalInvocation;
// [invocation setArgument:&view atIndex:2];
// [invocation setArgument:&bo atIndex:3];
// [invocation invoke];
// [invocation getReturnValue:&processTouches];
// if (processTouches) {
// //processTouches = pspdf_stylusShouldProcessTouches(touches, event);
// [invocation setReturnValue:&processTouches];
// }
//
// //[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(boom:) object:nil];
// [self performSelector:@selector(boom:) withObject:processTouches afterDelay:4];
//
// } error:NULL];
//
//
//
// unsigned int count;
// Method *methods = class_copyMethodList([MBProgressHUD class], &count);
// for (int i = 0; i < count; i++) {
// Method method = methods[i];
// SEL selector = method_getName(method);
// NSString *name = NSStringFromSelector(selector);
// NSLog(@"method_getName:%@",name);
// }
//
// unsigned int numIvars;
// Ivar *vars = class_copyIvarList([UITextView class], &numIvars);
// NSString *key=nil;
// for(int i = 0; i < numIvars; i++) {
//
// Ivar thisIvar = vars[i];
// key = [NSString stringWithUTF8String:ivar_getName(thisIvar)];
// NSLog(@"variable_name :%@", key);
// }
// free(vars);

你可能感兴趣的:(runtime框架 Aspects 类方法使用)