IOS Hook class member variables

Source: Internet
Author: User

It seems, in your case, you is trying to use an instance variable of the class is hooking. Modifying the instance variable does not work on that is the tweaks. You have the use of mshookivar to ' hooks ' an instance variable (aka Ivar). Example:

[TWEAK.XM/MM]

#import <substrate.h>//Necessary#import <Foundation/Foundation.h> @interface theclassyouarehooking: NSObject {    nsstring *_examplevariable;} -(void) dosomething; @endNSString *_examplevariablehooked;%hook theclassyouarehooking-(void) dosomething {    //' Hook ' the variable    examplevariablehooked = mshookivar<nsstring *> (self, "_examplevariable");    The name of the hooked variable does not need to being the same    examplevariablehooked = @ "Hello World";    You can do anything with the object Eg. [examplevariablehooked release];} %end

  

Mshookivar can also hook stuff like bools and floats etc.

examplevariablehooked = mshookivar<bool> (self, "_somebool");

  

Its declared in substrate.h so you need to import the otherwise you'll not being able to compile your tweak. Also as a bonus tip, I ' m just reminding you've had to put the identifier of the app/framework you ' re hooking in R tweakname.plist.

So after you ' hooks ' the variable you can change it to suit your needs. Happy coding!

IOS Hook class member variables

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.