Last active
February 25, 2019 21:22
-
-
Save casademora/753834752f3cb43b9b44 to your computer and use it in GitHub Desktop.
Private func in swift are hidden from the ObjC runtime
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
import Foundation | |
class Testing : NSObject | |
{ | |
private func privateWork() { | |
} | |
internal func internalWork(){ | |
} | |
func check(){ | |
self.respondsToSelector(Selector("privateWork")) //false | |
self.respondsToSelector(Selector("internalWork")) //true | |
} | |
} | |
let t = Testing() | |
t.check() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@objc private func privateWork() - Now you get true//true, because it had to make a dynamically dispatched version which performSelector can see... just something to keep in mind.