This is something I see all over Cocoa:
func someAction(_ sender: Any)
which is called like:
someAction(someObject)
This can be very confusing to me. The infamous example is in NSView
subclasses:
print("Hello, World!")
Despite this being standard Swift syntax for printing to the console, in an NSView
, this will open the printer dialog, claiming the sender is the String "Hello, World!"
. So, in my code I started doing this:
func someAction(sender: Any)
but I fear that the fact I see none of this in Cocoa means it's an anti-pattern. Is that the case, or am I in the right?