CaptainHook
If the class-dump file header found and known properties and methods
, for example, the following methods get (this method does not document, package exists ipa):
CustomViewController :UIViewController
@property (nonatomic, copy) NSString* newProperty;
+ (void)classMethod;
- (NSString*)getMyName;
- (void)newMethod:(NSString*) output;
- CHDeclareClass stated classes can call the properties and methods
CHDeclareClass(CustomViewController)
- Method calls and properties (Please read the attributes and methods of class-dump careful, here's how to call)
//方法已经明确写出了传什么
# optimization 当前self或者其他
#return_type 需要传入什么类型
#class_type 传入哪一个类
#name 属性名称
CHOptimizedMethod0(<#optimization#>, <#return_type#>, <#class_type#>, <#name#>)
CHOptimizedMethod0(self, NSString*, CustomViewController, getMyName){
//需要实现的代码
}
CHDeclareMethod1(void, CustomViewController, newMethod, NSString*, output){
//需要实现的代码
}
CHOptimizedClassMethod0(self, void, CustomViewController, classMethod){
//需要实现的代码
}
CHOptimizedMethod(0, self, NSString*, CustomViewController, newProperty)
{
//需要实现的代码
}
//需要实现的代码就是,你对以上传入属性值进行修改的,需要返回就returen,不需要则调用父类,或者直接不做任何操作
//添加新的属性
CHPropertyRetainNonatomic(CustomViewController, NSString*,
newProperty, setNewProperty);
- Constructor (CHConstructor)
`` `SWIFT
CHConstructor {
// load class
CHLoadLateClass (CustomViewController);
// the name of the class class method
CHClassHook0 (CustomViewController, getMyName);
CHClassHook0 (CustomViewController, classMethod);
// class name attribute
CHHook0 (CustomViewController, newProperty );
CHHook1 (CustomViewController, setNewProperty);
}