rolandleth / LTHPasscodeViewController

iOS 7 style Passcode Lock
MIT License
615 stars 143 forks source link

Extending LTHPasscodeViewController causes issues with bundle #179

Closed alvinpb closed 7 years ago

alvinpb commented 7 years ago

If you try and extend LTHPasscodeViewController, for example to add your own functionality or visual modifications, LTHPasscodeViewController will crash on touch-enabled phones after pin is setup and on first attempt of use.

Crashes on this section - specifically LTHPasscodeViewControllerStrings in LTHPasscodeViewController.m.

// Authenticate User
            [self.touchIDContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
                                localizedReason:LTHPasscodeViewControllerStrings(self.touchIDString)
                                          reply:^(BOOL success, NSError *error) {

To fix this - in the definition of LTHPasscodeViewControllerStrings -

#define LTHPasscodeViewControllerStrings(key) \
[[NSBundle bundleWithPath:[[NSBundle bundleForClass:[self class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName]

Instead of referencing [self class], reference [LTHPasscodeViewController class].

#define LTHPasscodeViewControllerStrings(key) \
[[NSBundle bundleWithPath:[[NSBundle bundleForClass:[LTHPasscodeViewController class]] pathForResource:@"LTHPasscodeViewController" ofType:@"bundle"]] localizedStringForKey:(key) value:@"" table:_localizationTableName]

Note - this might only be an issue when using LTHPasscodeViewController via cocoapods.

rolandleth commented 7 years ago

Hey, thanks for bringing it up, fixed in 3.8.7.