-
-
Save bumaociyuan/e777202a92b28382588ae4e8a83c1c68 to your computer and use it in GitHub Desktop.
A script for cycript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(exports) { | |
// 打印按钮的action及其target | |
zxactionWithTargets = function actionWithTargets(button) { | |
var allTargets = [button allTargets].allObjects(); | |
if (!allTargets) { | |
return "is not a uicontrol" | |
} | |
var allShow = []; | |
for (var i = 0; i < allTargets.length; i++) { | |
var target = allTargets[i]; | |
var actions = [button actionsForTarget: target forControlEvent: UIControlEventTouchUpInside]; | |
allShow.push("actions:" + actions + " target:" + target); | |
} | |
return allShow; | |
} | |
// 打印类的属性 | |
zxtryPrintIvars = function tryPrintIvars(a){ var x={}; for(i in *a){ try{ x[i] = (*a)[i]; } catch(e){} } return x; } | |
// 打印类的方法 | |
zxprintMethods = function printMethods(className, isa) { | |
var count = new new Type("I"); | |
var classObj = (isa != undefined) ? objc_getClass(className).constructor : objc_getClass(className); | |
var methods = class_copyMethodList(classObj, count); | |
var methodsArray = []; | |
for(var i = 0; i < *count; i++) { | |
var method = methods[i]; | |
methodsArray.push({selector:method_getName(method), implementation:method_getImplementation(method)}); | |
} | |
free(methods); | |
return methodsArray; | |
} | |
// 根据正则匹配需要的方法 | |
zxmethodsMatching = function methodsMatching(cls, regexp) { return [[new Selector(m).type(cls), m] for (m in cls.prototype) if (!regexp || regexp.test(m))]; } | |
// 替换OC的已有方法 | |
// 打印类的所有子类 | |
zxallSubClass = function allSubClass(className) { | |
return [c for each (c in ObjectiveC.classes) if (class_getSuperclass(c) && [c isSubclassOfClass:className])] | |
} | |
})(exports); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment