mirror of
https://github.com/ypresto/SwiftLintXcode.git
synced 2026-03-25 08:55:51 +00:00
🔧 Guard Method values in swizzle()
This commit is contained in:
parent
5cb965ea10
commit
6101a95d39
1 changed files with 5 additions and 2 deletions
|
|
@ -24,8 +24,11 @@ final class SaveHook {
|
|||
if swizzled { return }
|
||||
swizzled = true
|
||||
|
||||
let fromMethod = class_getInstanceMethod(NSDocument.self, #selector(NSDocument.save(withDelegate:didSave:contextInfo:)))
|
||||
let toMethod = class_getInstanceMethod(NSDocument.self, #selector(NSDocument.swiftLintXcodeSaveDocument(delegate:didSaveSelector:contextInfo:)))
|
||||
guard let fromMethod = class_getInstanceMethod(NSDocument.self, #selector(NSDocument.save(withDelegate:didSave:contextInfo:))),
|
||||
let toMethod = class_getInstanceMethod(NSDocument.self, #selector(NSDocument.swiftLintXcodeSaveDocument(delegate:didSaveSelector:contextInfo:))) else {
|
||||
return
|
||||
}
|
||||
|
||||
method_exchangeImplementations(fromMethod, toMethod)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue