Hooking Instance Variables

From iPhone Development Wiki
Revision as of 04:27, 28 March 2015 by Ninjaprawn (talk | contribs) (Created the page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page is dedicated to the use of the MSHookIvar function, included in Mobile Substrate, to modify instance variables.


Usage

The code works in the following format:
MSHookIvar<Class*>(varForIvar, "ivar_name")

A number of things need to be noted:

   1. The class can be any sort of class: C class (int, char, etc.), or any other Objective-C Class (CGRect, UILabel*, etc.)
   2. The varForIvar is commonly the variable that contains the instance variable you are hooking
   3. IMPORTANT: the ivar_name is a C String, not an Objective-C String (so no @ sign)