Jump to content

Error "warning: missing %end" when I have %end!?


antifile

1 post in this topic

Recommended Posts

Posted

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!

Archived

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

×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines