Skip to content
This repository was archived by the owner on Aug 14, 2019. It is now read-only.

Commit 9c43534

Browse files
committed
follow up for #1247 and #1591. obfuscate private APIs. swizzle via +initialize
1 parent 5cb6acf commit 9c43534

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

JSQMessagesViewController/Controllers/JSQMessagesViewController.m

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,18 @@ const void (^swizzleOnClass)(Class k) = ^(Class klass) {
9999
removeWorkaround();
100100
});
101101
};
102-
swizzleOnClass(NSClassFromString(@"_UIRotatingAlertController"));
103-
swizzleOnClass(NSClassFromString(@"WKActionSheet"));
102+
103+
// _UIRotatingAlertController
104+
Class alertClass = NSClassFromString([NSString stringWithFormat:@"%@%@%@", @"_U", @"IRotat", @"ingAlertController"]);
105+
if (alertClass) {
106+
swizzleOnClass(alertClass);
107+
}
108+
109+
// WKActionSheet
110+
Class actionSheetClass = NSClassFromString([NSString stringWithFormat:@"%@%@%@", @"W", @"KActio", @"nSheet"]);
111+
if (actionSheetClass) {
112+
swizzleOnClass(actionSheetClass);
113+
}
104114
}
105115

106116

@@ -148,6 +158,13 @@ + (instancetype)messagesViewController
148158
bundle:[NSBundle bundleForClass:[JSQMessagesViewController class]]];
149159
}
150160

161+
+ (void)initialize {
162+
[super initialize];
163+
if (self == [JSQMessagesViewController self]) {
164+
JSQInstallWorkaroundForSheetPresentationIssue26295020();
165+
}
166+
}
167+
151168
#pragma mark - Initialization
152169

153170
- (void)jsq_configureMessagesViewController
@@ -194,8 +211,6 @@ - (void)jsq_configureMessagesViewController
194211
panGestureRecognizer:self.collectionView.panGestureRecognizer
195212
delegate:self];
196213
}
197-
198-
JSQInstallWorkaroundForSheetPresentationIssue26295020();
199214
}
200215

201216
- (void)dealloc

0 commit comments

Comments
 (0)