[swift-evolution] [Discussion] Referencing the Objective-C selector of property getters and setters
Adrian Kashivskyy
adrian.kashivskyy at me.com
Fri Mar 4 02:52:08 CST 2016
I'm +1 on this as well.
Pozdrawiam – Regards,
Adrian Kashivskyy
> Wiadomość napisana przez David Hart via swift-evolution <swift-evolution at swift.org> w dniu 25.02.2016, o godz. 08:38:
>
> Now that I’m thinking about it, wouldn’t my need be better served by a different proposal for:
>
> #key(Person.firstName) // returns the string “firstName”
> #keyPath(Person.mother.firstName) // returns the string “mother.firstName”
>
> How doable is the keyPath version?
>
>> On 25 Feb 2016, at 08:10, David Hart via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> 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
>>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160304/b4f44e8e/attachment.html>
More information about the swift-evolution
mailing list