#import <UIKit/UIAlertView.h>
@class NSObject;
@interface SBIconController : NSObject
+ (SBIconController *)sharedInstance;
- (BOOL)isEditing;
@end
%hook SBIconController
-(void)iconTapped:(id)tapped {
SBIconController *sbic = [objc_getClass("SBIconController") sharedInstance];
if ([sbic isEditing]) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Message" message:[NSString stringWithFormat:@"%@", tapped] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
%orig;
}
%end
Above is a simple tweak that I have created with Logos. For some reason after installing, nothing is working, I just can't figure out what the problem is and How can I solve this problem?
Other questions that I have are:
SBIconController
when there's already a SBIconController
class?NSObject
?[SBIconController sharedInstance]
instead of [objc_getClass("SBIconController") sharedInstance]
?Thanks a lot for your help!
The code is fine. I tested it (I don't use logos) and iconTapped:
method is indeed called when you tap an app icon. But what are you trying to achieve with isEditing
? This property indicates whether you are editing SpringBoard (tap and hold an app icon) and when it equals YES
method iconTapped:
is NOT called when icon is tapped. It's called only when isEditing
equals NO
. So I suggest you insert alert without if ([sbic isEditing])
to test whether your tweak is working.
As for your other questions:
SBIconController
. To solve this problem we can either download headers that others dumped using various tools like class-dump or declare these private APIs yourself. In your case it's latter.SBIconController
inherits from NSObject
.You can do it either way. Of course, when you have class declaration you don't need to use objc_getClass
. And in your case you don't even need either of this things. You can just use self
like you would in any other obj-C method. Your code will look like this:
%hook SBIconController
-(void)iconTapped:(id)tapped {
if ([self isEditing]) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Message" message:[NSString stringWithFormat:@"%@", tapped] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
%orig;
}
%end