[swift-evolution] [Discussion] Referencing the Objective-C selector of property getters and setters

David Hart david at hartbit.com
Thu Feb 25 01:10:01 CST 2016


In the original thread, my use case was the ability to get type-safety for key-value coding:

david.setValue(30, forKey: String(#selector(getter: Person.age)))

On 25 Feb 2016, at 06:50, Brent Royal-Gordon <brent at architechies.com> wrote:

>> Motivation
>> 
>> The #selector feature is very useful but does not yet cover all cases. Accessing poperty getter and setters requires to drop down to the string syntax and forgo type-safety. This proposal supports this special case without introducing new syntax, but by introducing new overloads to the #selector compiler expression.
> 
> What I don't understand is, what's the use case? When you want to access properties dynamically in Objective-C, you usually use key-value coding, not selectors. Can you point to APIs it would be helpful to use this with, or write some realistic code which uses this feature? Or is this basically just completeness for the sake of completeness?
> 
> -- 
> Brent Royal-Gordon
> Architechies
> 


More information about the swift-evolution mailing list