So granted, I am very new to tweak development, but I'm running into an issue. I'm working on a tweak for personal use that hooks into multiple processes, but I'm having difficulty sharing a variable between those process-specific hooks. For instance, my SpringBoard method hooks are able to set the value of a static variable and then access the value set. But the app-specific method hooks are unable to retrieve the value set within the context of a SpringBoard method. The variable is coming back uninitialized.
Since the tweak library is common, how can I initialize a "global" library-level variable within the context of one process' hook and access that value within the context of another process.
My first attempts look something like this:
static BOOL isEnabled;
%hook FirstProcessFirstClass
- (void) methodInFirstProcessFirstClass {
isEnabled = YES;
%orig;
}
%end
%hook FirstProcessSecondClass
- (void) methodInFirstProcessSecondClass {
// This will be 1 if it occurs after methodInFirstProcessFirstClass
NSLog("isEnabled equals %d", isEnabled);
%orig;
}
%end
%hook SecondProcessClass
- (void) methodInSecondProcessClass {
// This is always going to be uninitialized (i.e., 0)
NSLog("isEnabled equals %d", isEnabled);
%orig;
}
%end
You get the picture, I'd like to share a "global variable" between hooked processes. Thanks for humoring me. :/