Created
December 2, 2019 17:05
-
-
Save kyle-ilantzis/00f4685462a150506481a15ac2af7259 to your computer and use it in GitHub Desktop.
autofill SMS code webview crash https://openradar.appspot.com/7428013
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func swizzleReplacingCharacters() { | |
let originalMethod = class_getInstanceMethod( | |
NSString.self, #selector(NSString.replacingCharacters(in:with:))) | |
let swizzledMethod = class_getInstanceMethod( | |
NSString.self, #selector(NSString.swizzledReplacingCharacters(in:with:))) | |
guard let original = originalMethod, let swizzled = swizzledMethod else { | |
return | |
} | |
method_exchangeImplementations(original, swizzled) | |
} | |
extension NSString { | |
@objc | |
func swizzledReplacingCharacters(in range: NSRange, with replacement: String) -> String { | |
/// By simply calling the original method the nil argument is handled. :shrug: :ok: | |
/// | |
/// (yes, we will call the original method and not ourselves even though it looks like it, | |
/// because the methods have been swapped.) | |
return self.swizzledReplacingCharacters(in: range, with: replacement) | |
} | |
} |
@kyunkakata Thanks your code :)
Can I use your code in my commercial app?
Please let me know how I can use the code for commercial distribution.
That was @623637646 's code.
hi @seyoung-hyun . Feel free to use it. do remember to test before release to live.
@kyunkakata Sorry for confusing you.
@623637646 Thanks your reply :)
hi @kyle-ilantzis.
I wonder if I use your code at this gist in my commercial app, too.
Please let me know how I can use the code for commercial distribution.
Thanks :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you @623637646