[swift-evolution] [Discussion] Referencing the Objective-C selector of property getters and setters
David Hart
david at hartbit.com
Tue Mar 15 02:44:56 CDT 2016
Wouldn't it be:
#selector(getter: NSString.lowercaseString))
To allow us to disambiguate getters and setters?
> On 15 Mar 2016, at 06:09, Keith Smiley <keithbsmiley at gmail.com> wrote:
>
> Another reasonable use case for this is with `UILocalizedIndexedCollation`. For example with Swift 2.1:
>
> ```
> let collation = UILocalizedIndexedCollation.currentCollation()
> collation.sectionForObject("something", collationStringSelector: "lowercaseString") // NSString.lowercaseString
> ```
>
> Currently the Xcode quickfix is:
>
> ```
> collation.sectionForObject("something", collationStringSelector: Selector("lowercaseString"))
> ```
>
> But I guess ideally this would work something like:
>
> ```
> collation.sectionForObject("something", collationStringSelector: #selector(NSString.lowercaseString))
>
> --
> Keith Smiley
>
> On 02/24, Brent Royal-Gordon via swift-evolution 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160315/4cac9d87/attachment.html>
More information about the swift-evolution
mailing list