Skip to content
Guest Big Announcement

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

Featured Replies

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.

Featured Content

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.