2

I wrote a tweak for cydia, but it does not seem to be working. I created the template using Theos. I got a header dump from the iosod tool, and found

`$` - (void)searchBarTextDidBeginEditing:(id)searchBarText;

inside of the SBSearchController class. Here is the code I have in the Tweak.

%hook SBSearchController

- (void)searchBarTextDidBeginEditing:(id)searchBarText { %orig;

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Tweak"
    message:@"Testing is running!"
    delegate:nil
    cancelButtonTitle:@"Ok"
    otherButtonTitles:nil];
[alert show];
[alert release];`

}

%end

and my Makefile looks like this

include theos/makefiles/common.mk  

Testing_FRAMEWORKS = UIKit  

TWEAK_NAME = Testing  

Testing_FILES = Tweak.xm    

include $(THEOS_MAKE_PATH)/tweak.mk \

Everything compiles and installs correctly, but at runtime, when I tap on the search bar, and begin to type, nothing happens. Does anybody know what I did wrong?

Thanks!

Bo.
  • 2,547
  • 3
  • 24
  • 36
user1455332
  • 121
  • 7

1 Answers1

1

Remember that since this is a delegate method it won't be called unless the delegate class implements the method. Have you tested this on an application which handles this event?

Try adding some logging to a file so you can see whether your code is being called or not.

  • I added a hook for the init method, and that one worked well. So you are right, the delegate method was never called. So if isod is lying to me, how can I find the real call? – user1455332 Jun 14 '12 at 14:24
  • If you create a basic app that implements that delegate call you should be able to see if your hook is working. Since your hooks are working for the init call, as an alternative to hooking a delegate function, you could take a look at the private headers and see if there are any private calls that handle events on that text field, if you hook those then you wouldn't need to rely on the apps using the controller implementing the delegate call. –  Jun 14 '12 at 17:42
  • Do you know where I could get a hold of these private headers? people sometimes refer to the /var/SDK/S/L/Frameworks folder, but it doesn't seem to have all of them. – user1455332 Jun 14 '12 at 21:44
  • See [rpetrich's iPhone Headers](https://github.com/rpetrich/iphoneheaders) for a set of private headers that can be used with theos –  Jun 15 '12 at 09:31
  • Its funny that so many of those methods are never called. Seems like a lot of overhead for no reason. Anyways, thanks for you answers! – user1455332 Jun 15 '12 at 19:17