Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sfiq12

macrumors newbie
Original poster
May 1, 2012
1
0
Code:
#import <Foundation/Foundation.h>
#import <Preferences/Preferences.h>
#import <UIKit/UIKit.h>
//=>SBScreenflash
#import <SpringBoard/SpringBoard.h>

%hook SBScreenFlash
-(void)_createUIWithColor:(UIColor*)color
{
** * * *%orig;
** * * *static UIImageView* myImageView;
** * * *UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"/var/mobile/PonifyMyiPhone.png"]];
** * * *myImageView.frame = CGRectZero;
** * * *myImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
** * * *[MSHookIvar<UIWindow *>(self, "_flashWindow") addSubview:myImageView];
}
-(void)_tearDown
{
%orig;
[myImageView release];
}
%end

%hook SBApplicationIcon
-(void)launch
{
%orig;*
NSDictionary *dict = [[NSDictionary alloc]
initWithContentsOfFile:
@"/var/mobile/Library/Preferences/com.sfiq12.ponifymyiphone.plist"
];
if ([[dict objectForKey:@"Enable"] boolValue])
{*
*int rand = arc4random() % 5;
**UIColor *color = [UIColor whiteColor];
**switch(rand){
**case 0: color = [UIColor purpleColor]; break;
** case 1: color = [UIColor cyanColor]; break;
** *case 2: color = [UIColor yellowColor]; break;
** * * *case 3: color = [UIColor orangeColor]; break;
** * * *case 4: color = [UIColor magentaColor]; break;
** *}
** *[[%c(SBScreenFlash) sharedInstance]flashColor:color];
}
[dict release];
}
%end

I'm trying to get the SBScreenFlash to flash an image but I keep failing. I'm not sure why or what's wrong but, here's the error code :|
Code:
Tweak.xm: In function 'void _logos_method$_ungrouped$SBScreenFlash$_createUIWithColor$(SBScreenFlash*, objc_selector*, UIColor*)':
Tweak.xm:12: error: redeclaration of 'UIImageView* myImageView'
Tweak.xm:11: error: 'UIImageView* myImageView' previously declared here
Tweak.xm: In function 'void _logos_method$_ungrouped$SBScreenFlash$_tearDown(SBScreenFlash*, objc_selector*)':
Tweak.xm:20: error: 'myImageView' was not declared in this scope
Tweak.xm: In function 'void _logos_method$_ungrouped$SBApplicationIcon$launch(SBApplicationIcon*, objc_selector*)':
Tweak.xm:43: warning: no '-flashColor:' method found
Tweak.xm:43: warning: (Messages without a matching method signature
Tweak.xm:43: warning: will be assumed to return 'id' and accept
Tweak.xm:43: warning: '...' as arguments.)
make[2]: *** [obj/Tweak.xm.o] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [PonifyMyiPhone.all.tweak.variables] Error 2
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.