• In the last article, we talked about how to package and use the.cy script file. Here we use MJ’s Sunshine to package some common operations, which can help to quickly analyze the software. We will continue to update the script based on this.

  • There are notes in the script, you can download their own to see, the following will install the use of part of the method, the other method is similar, you can refer to or write their own.

  • In fact, it is not difficult, that is JS + OC, will front-end plus iOS development can be written out, behind can add some difficult things.

One, installation script

1. Download the DZMCycript script

Use the “/usr/lib/cycript0.9” command to import the.cy script.

$ scp -P 10010 /Users/dengzemiao/Desktop/GitHub/DZMCycript/DZMCycript.cy root@localhost:/usr/lib/cycript0.9
Copy the code

3. After the file is imported into the mobile phone, the mobile terminal is entered

dengzemiaodeMacBook-Pro:ssh dengzemiao$ sh login.sh
iPhone:~ root#
Copy the code

4. Enter the debugging environment through Cycript listening software and import DZMCycript scripts

IPhone :~ root# sycript -p neteasemusic // The script was imported successfully cy# @import DZMCycript {} // The script cy# DZMAppId was used @"com.netease.cloudmusic" cy# DZMFrontVc() #"<NMSettingTabViewController: 0x118a337a0>"Copy the code

The following is to introduce the use of some methods, can use can not see!! .


Second,DZMFrontVc() DZMRectMake(x, y, w, h)Test: Add UI view to any APP

IPhone :~ root# cycript -p neteasemusic DZMCycript cy# @import DZMCycript {} // Get the current top controller (if there is a controller nested what this needs to pay attention to yourself, you can use the script inside or own iOS code to get the current controller, If no nested generally can be normal access to) cy# DZMFrontVc () # < NMPhoneLoginViewController:" 0 x10a968340 > add a red "/ / the View to the software page / / create redView cy# var redView = [[UIView alloc] initWithFrame: DZMRectMake (50, 50, 100, 100)] #"<UIView: 0x114f3bef0; frame = (50 50; 100, 100); layer = <CALayer: 0x280C718C0 >>" // Set the color cy# redView.backgroundColor = [UIColor redColor] #"UIExtendedSRGBColorSpace 1 0 0 1" // add to the current controller View addSubview: redView [0x10a968340.Copy the code

Three,DZMLoadFramework(name)Test: add system libraries to software dynamically

  • For example, if we want to add a map to an APP, but the APP does not import the map library MapKit.framework, then we cannot use the map object MKMapView to create a map. If we do not import the library directly to create a map object, we will report an error.

  • Dynamically importing libraries via DZMCycript scripts and using them is the same as iOS development

IPhone :~ root# cycript -p neteasemusic DZMCycript cy# @import DZMCycript {} // Get the current controller CY# DZMFrontVc() #"<NMPhoneLoginViewController: 0x1121d5d20>" Strings can be cy# DZMLoadFramework (' MapKit ') # "NSBundle < / System/Library/Frameworks/MapKit framework > (the loaded)" / / create the MapView cy# var mapView = [[MKMapView alloc] initWithFrame: DZMRectMake(50, 50, 100, 100)] #"<MKMapView: 0x10b3c5c00; frame = (50 50; 100, 100); clipsToBounds = YES; Layer = <CALayer: 0x280cd9c20>>" layer = <CALayer: 0x280cd9c20>>"Copy the code

Four,DZMInstanceMethodNames(className, reg)Test: get the object methods in the specified object, so that we can get the methods in any object, so that we can not manually call

/ / get the current controller login controller cy# DZMFrontVc () # < NMPhoneLoginViewController:" Cy# DZMInstanceMethodNames(#0x1121d5d20) [&"backAction:",&"pageName",&"notNeedShowShareMenu",&"loginView",&"stopActivityWithText:",&"onResetPhoneClicked:",&"capt chaDidChanged:",&"onCaptchaReturn",&"onEditPhoneButtonDidClicked:",&"setLoginView:",&"captchaView",&"setCurrentPhoneNumb erExist:",&"setCurrentPhoneNumberNickname:",&"setCaptchaView:",&"_passwordLoginButtonDidClicked:",&"currentPhoneNumberEx ist",&"setIsVerifyingCaptcha:",&"_dismissCapthcaView:",&"currentPhoneNumberNickname",&"phoneNumberViewNextButtonClicked: ",&"phoneNumberViewTextDidChanged:",&"resendButtonClicked:",&"isVerifyingCaptcha",&"startActivity",&"init",&"dealloc",&" .cxx_destruct",&"viewWillAppear:",&"viewWillDisappear:",&"viewDidLoad",&"viewDidAppear:",&"shouldAutorotateToInterfaceOr ientation:"]Copy the code

  • You can see insideReturn to the event,Log events,Declare periodic function. All get, get after you can manually call, object call method properties need not teach it.
// Regular expression filtering is also supported How you use regular filtering depends on your level of regular usage. /Click/) [&"onResetPhoneClicked:",&"onEditPhoneButtonDidClicked:",&"_passwordLoginButtonDidClicked:",&"phoneNumberViewNextButtonC licked:",&"resendButtonClicked:"]Copy the code

Five,DZMIvarNames(obj, reg)Test: Gets all the member variable names of the object

Cy# DZMIvarNames(#0x1121d5d20, /view/)Copy the code

Vi.DZMSublasses(className, reg)Test: output all subclasses of the specified type, that is, all classes that inherit from the specified class

Cy# DZMSublasses(UIViewController) UIViewController (UIViewController) See if there's a custom navigation bar cy# DZMSublasses(UINavgationController) that will help you quickly find some classes or controllers and narrow it down to....Copy the code

Seven,DZMChildVcs(vc)Test: get all the child controllers in the specified controller, and try other methods to get the child view, for exampleDZMSubviews(view)

Cy# DZMChildVcs(DZMRootVc()))Copy the code