Hey everyone!
So I've got this tweak I'm making via Zane Helton's tutorials. I've hooked UIViewController and ive %end'ed it at the end but it still says that I'm missing my %end..
Can someone shine any light onto why this is happening?
Here's the code:
@interface BCBatteryDeviceController {
NSArray *_sortedDevices;
}
+(id)sharedInstance;
@end
@interface BCBatteryDevice {
long long _percentCharge;
NSString *_name;
}
@end
%hook UIViewController
- (void)presentViewController:(UIViewController *)viewControllerToPresent
animated:(BOOL)flag
completion:(void (^)(void))completion {
//no code would run without orig
if ([viewControllerToPresent isKindOfClass[UIAlertController class]]) {
UIAlertController *ac = (UIAlertController *)viewControllerToPresent;
BCBatteryDeviceController *bcb = [%c(BCBatteryDeviceController) sharedInstance];
NAArrray *devices = MSHookIvar<NSArray *>(bcb, "_sortedDevices");
NSMutableString *newMessage = [NSMutableString new];
for (BCBatteryDevice *device in devices) {
NSString *deviceName = MSHookIvar<NSString *>(device, "_name");
long long deviceCharge = MSHookIvar<long long>(device, "_percentCharge");
[newMessage appendString:@"%@ : %lld%%\n", deviceName, deviceCharge];
}
[ac setMessage:newMessage];
return %orig(ac, flag, completion);
} else {
return %orig;
}
}
%end
Thanks for any help guys!