Skip to content
Guest Big Announcement

How to make a void work with PreferenceBundle?

Featured Replies

I am trying to use a void and make a switch to turn it off or on. I am not trying to return a void as a bool or id. I am simply trying to return it %orig.

Example:

%hook Play
-(void) disableIfWatching {
  if(GetPrefBool (@"test")) {
return %orig;
}
return %orig;
}
%end

%ctor {
    %init(Play = objc_getClass("Hydra.WatchController"));
}

I have compiled it and work only when the switch is off which is the problem. I'd like it to work like a normal switch when it's on. 

Example of .plist:

		<dict>
			<key>action</key>
			<string>info</string>
			<key>cell</key>
			<string>PSSwitchCell</string>
			<key>default</key>
			<false/>
			<key>defaults</key>
			<string>test.com</string>
			<key>key</key>
			<string>test</string>
			<key>label</key>
			<string>Testing Void Switch</string>
		</dict>

Yes, the void does do something which is why I'd like to make it work with my preferencebundle. I have tested in Flex and it does void whatever it is supposed to do.

 

Edit: When I remove the second %orig; from tweak.xm, it work but when the switch is off. When both %orig; are in tweak.xm, the switch doesn't work at all.

Updated by Astronaut

You need a value it cannot simply be

return %orig :facepalm:

if you don’t know what %orig is I recommend you look up a tut

maybe im worng it might only work with - (bool)

Updated by Red16

Try this

%hook Play
-(void) disableIfWatching:(id)arg1 {
  if(GetPrefBool (@"test")) {
%end

%ctor {
    %init(Play = objc_getClass("Hydra.WatchController"),Play=objc_getClass("Hydra.WatchController"));};

may not work I still learning my self 

Archived

This topic is now archived and is closed to further replies.

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.