[swift-evolution] [Accepted] SE-0064: Referencing the Objective-C selector of property getters and setters

Robert Schwalbe roberts at inode.com
Mon Apr 18 18:11:20 CDT 2016


> Hello Robert,
> 
> My comment below:
> 
>> Per my reading of SE-0022, would SE-0064 institute the first exception to the #selector expression where the expression is not a reference to a method?
> 
> Indeed. But I don’t see the issue. It still generates a selector for an Objective-C method.

Thank you David.

I do agree it generates a selector. My objection would be that there are no Objective-C methods named “getter” or “setter”.

>> In the spirit of taking my lumps for not speaking up when asked to do so, was there any discussion that considered:
>> 
>>   let firstNameGetter = #selector(get: Person.firstName)
>>   let firstNameSetter = #selector(set: Person.firstName)
>> 
>> in lieu of the accepted:
>> 
>>   let firstNameGetter = #selector(getter: Person.firstName)
>>   let firstNameSetter = #selector(setter: Person.firstName)
>> 
>> My concern would be a growing list of permitted non method name parameters to the #selector expression.
> 
> I don’t think get/set was specifically mentioned. My personal opinion is that it does not read well because it reads as an action.

I could go along with you that it reads as an action, but I also think we could come up with tons of existing toolbox method names that would also read as actions.

Maybe I am hung up on insisting that the expression must be an actual name of an Objective-C method.


More information about the swift-evolution mailing list