[swift-evolution] [swift-dev] Is there an underlying reason why optional protocol requirements need @objc?

Brent Royal-Gordon brent at architechies.com
Fri Mar 4 16:55:33 CST 2016


> In delegation patterns it can be very helpful in terms of optimization (performance and memory) if the delegator can interrogate a delegate to know if certain delegation points are needed or not. I have code that has done this interrogation at delegate registration allowing potentially complex code paths and/or state maintenance to be avoided.

You can always add another delegation point along the lines of `shouldDoTheExpensiveThing()`. Or introduce a FooDelegateWithExpensiveThing protocol which conforms to FooDelegate, and test at runtime to see if your delegate is a FooDelegateWithExpensiveThing.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list