Skip to content
Guest Big Announcement

Code keep return %orig;

Featured Replies

%hook targetClass
-(bool)istargetmethodActive{
	
	if ([[prefs objectForKey:@"keyFromPlist"] boolValue]){

		return true;

	}

	return %orig;

}
%end

I've tried running and make countless changes but the results is still the same. The problem is, when I try On or Off my tweak via Preference (in Settings app), the code keep return %orig;

 

Please help.

Solved by castix

  • Author

istargetmethodActive is case sensitive, have you copied it correctly?

 

Yes. I'm 100% sure and confident. I just want a simple workflow:

 

1. User turn the switch OFF = The tweak is not working.

2. User turn the switch ON = The tweak is working.

 

Unfortunately, nothing seems to work according my plan.


-(bool)istargetmethodActive{

 

if ([[prefs objectForKey:@"keyFromPlist"] boolValue]){

 

return true;

 

} else {

 

return %orig;

 

}

%end

  • Author
-(bool)istargetmethodActive{
	
	if ([[prefs objectForKey:@"keyFromPlist"] boolValue]){

		return true;

	} else {

	return %orig;

}
%end

Got this error while processing to package... 

Tweak.xm:46: error: %end does not make sense inside a block
  • Author

Forgot to close out. Set another } at the end

 

Thanks, code my code it's working now. But it seems I'm facing another problem. 

 

Quote fro Stackoverflow

 

 

 

If the key does not exist in the user defaults, the result of this method will be NO.

 

I'm facing this issue now. I think /Library/PreferenceBundles/yourtweak.bundle/yourplistname.plist  can't be read by Preference.

  • Solution

Thanks, code my code it's working now. But it seems I'm facing another problem. 

 

Quote fro Stackoverflow

 

 

I'm facing this issue now. I think /Library/PreferenceBundles/yourtweak.bundle/yourplistname.plist  can't be read by Preference.

#define kPath @"/var/mobile/Library/Preferences/YOUR_PLIST_NAME.plist"


%hook targetClass
-(bool)istargetmethodActive {
NSDictionary *prefs=[[NSDictionary alloc] initWithContentsOfFile:kPath];
%orig;
    if ([[prefs objectForKey:@"keyFromPlist"] boolValue]){
    return true;
    } else {
    return %orig;
  }
}
%end

Updated by castix

  • Author
#define kPath @"/var/mobile/Library/Preferences/YOUR_PLIST_NAME.plist"


%hook targetClass
-(bool)istargetmethodActive {
NSDictionary *prefs=[[NSDictionary alloc] initWithContentsOfFile:kPath];
%orig;
    if ([[prefs objectForKey:@"keyFromPlist"] boolValue]){
    return true;
    } else {
    return %orig;
  }
}
%end

 

Thanks castix! It's working now!   xD

Create an account or sign in to comment

Featured Content

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.