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

**URL:** <https://forums.swift.org/t/accepted-se-0064-referencing-the-objective-c-selector-of-property-getters-and-setters/2199>\
**Category:** Announcements\
**Created:** [April 14, 2016, 10:58pm UTC](https://forums.swift.org/t/accepted-se-0064-referencing-the-objective-c-selector-of-property-getters-and-setters/2199 "2016-04-14T22:58:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Douglas\_Gregor](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/douglas_gregor/32/1362_2.png) [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Post date:** [April 14, 2016, 10:58pm UTC](https://forums.swift.org/t/accepted-se-0064-referencing-the-objective-c-selector-of-property-getters-and-setters/2199/1 "2016-04-14T22:58:51Z")

</div>

Proposal link: [swift-evolution/0064-property-selectors.md at master · apple/swift-evolution · GitHub](https://github.com/apple/swift-evolution/blob/master/proposals/0064-property-selectors.md)

Hello Swift Community,

The review of SE-0064 "Referencing the Objective-C selector of property getters and setters” ran from April 7...12, 2016. The proposal is accepted. Feedback was light but positive, with many considering this to effectively be an obviously-missing piece of the #selector proposal (SE-0022 \<[https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md&gt;\](https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md&gt;%5C)).

We welcome an implementation of this proposal. I’ve filed a ticket at

&nbsp;&nbsp;[[SR-1239] Implement SE-0064: Referencing the Objective-C selector of property getters and setters · Issue #43847 · apple/swift · GitHub](https://bugs.swift.org/browse/SR-1239)

to track the implementation.

&nbsp;&nbsp;- Doug

---

<div class="post-metadata">

**Author:** ![jtbandes](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jtbandes/32/463_2.png) [@jtbandes](https://forums.swift.org/u/jtbandes)\
**Post date:** [April 15, 2016, 7:53am UTC](https://forums.swift.org/t/accepted-se-0064-referencing-the-objective-c-selector-of-property-getters-and-setters/2199/2 "2016-04-15T07:53:17Z")

</div>

Was the syntax fully bikeshedded by the core team before acceptance?  
Perusing the API guidelines, one could also imagine:

&nbsp;&nbsp;&nbsp;&nbsp;#selector(setting: Person.name)  
&nbsp;&nbsp;&nbsp;&nbsp;#selector(forSetting: Person.name)

> **···**
>
> On Thu, Apr 14, 2016 at 3:58 PM, Douglas Gregor via swift-evolution \< swift-evolution@swift.org\> wrote:
> 
> > Proposal link:  
> > [https://github.com/apple/swift-evolution/blob/master/proposals/0064-property-selectors.md](https://github.com/apple/swift-evolution/blob/master/proposals/0064-property-selectors.md)
> > 
> > Hello Swift Community,
> > 
> > The review of SE-0064 "Referencing the Objective-C selector of property  
> > getters and setters” ran from April 7...12, 2016. The proposal is  
> > \*accepted\*. Feedback was light but positive, with many considering this  
> > to effectively be an obviously-missing piece of the #selector proposal (  
> > SE-0022  
> > \<[https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md&gt](https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md&gt);  
> > ).
> > 
> > We welcome an implementation of this proposal. I’ve filed a ticket at
> > 
> > [[SR-1239] Implement SE-0064: Referencing the Objective-C selector of property getters and setters · Issue #43847 · apple/swift · GitHub](https://bugs.swift.org/browse/SR-1239)
> > 
> > to track the implementation.
> > 
> > - Doug
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-evolution mailing list  
> > swift-evolution@swift.org  
> > [https://lists.swift.org/mailman/listinfo/swift-evolution](https://lists.swift.org/mailman/listinfo/swift-evolution)

---

<div class="post-metadata">

**Author:** ![Robert\_Schwalbe1](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Schwalbe1](https://forums.swift.org/u/Robert_Schwalbe1)\
**Post date:** [April 16, 2016, 6:20pm UTC](https://forums.swift.org/t/accepted-se-0064-referencing-the-objective-c-selector-of-property-getters-and-setters/2199/3 "2016-04-16T18:20:57Z")

</div>

I realize I am quite late to this discussion, so if a public flogging is in order I am willing to accept that (and the rest of this e-mail can be ignored and/or deleted from the archives).

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?

In the spirit of taking my lumps for not speaking up when asked to do so, was there any discussion that considered:

&nbsp;&nbsp;&nbsp;&nbsp;let firstNameGetter = #selector(get: Person.firstName)  
&nbsp;&nbsp;&nbsp;&nbsp;let firstNameSetter = #selector(set: Person.firstName)

in lieu of the accepted:

&nbsp;&nbsp;&nbsp;&nbsp;let firstNameGetter = #selector(getter: Person.firstName)  
&nbsp;&nbsp;&nbsp;&nbsp;let firstNameSetter = #selector(setter: Person.firstName)

My concern would be a growing list of permitted non method name parameters to the #selector expression.

---

<div class="post-metadata">

**Author:** ![hartbit](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hartbit/32/738_2.png) [@hartbit](https://forums.swift.org/u/hartbit)\
**Post date:** [April 15, 2016, 12:03pm UTC](https://forums.swift.org/t/accepted-se-0064-referencing-the-objective-c-selector-of-property-getters-and-setters/2199/4 "2016-04-15T12:03:50Z")

</div>

Why? What guideline are you referencing?

> **···**
>
> > On 15 Apr 2016, at 09:53, Jacob Bandes-Storch via swift-evolution \<swift-evolution@swift.org\> wrote:
> > 
> > Was the syntax fully bikeshedded by the core team before acceptance? Perusing the API guidelines, one could also imagine:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;#selector(setting: Person.name)  
> > &nbsp;&nbsp;&nbsp;&nbsp;#selector(forSetting: Person.name)
> > 
> > On Thu, Apr 14, 2016 at 3:58 PM, Douglas Gregor via swift-evolution \<swift-evolution@swift.org \<mailto:swift-evolution@swift.org\>\> wrote:  
> > Proposal link: [https://github.com/apple/swift-evolution/blob/master/proposals/0064-property-selectors.md](https://github.com/apple/swift-evolution/blob/master/proposals/0064-property-selectors.md)
> > 
> > Hello Swift Community,
> > 
> > The review of SE-0064 "Referencing the Objective-C selector of property getters and setters” ran from April 7...12, 2016. The proposal is accepted. Feedback was light but positive, with many considering this to effectively be an obviously-missing piece of the #selector proposal (SE-0022 \<[https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md&gt;\](https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md&gt;%5C)).
> > 
> > We welcome an implementation of this proposal. I’ve filed a ticket at
> > 
> > &nbsp;&nbsp;[[SR-1239] Implement SE-0064: Referencing the Objective-C selector of property getters and setters · Issue #43847 · apple/swift · GitHub](https://bugs.swift.org/browse/SR-1239)
> > 
> > to track the implementation.
> > 
> > &nbsp;&nbsp;- Doug
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-evolution mailing list  
> > swift-evolution@swift.org \<mailto:swift-evolution@swift.org\>  
> > [https://lists.swift.org/mailman/listinfo/swift-evolution](https://lists.swift.org/mailman/listinfo/swift-evolution)
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-evolution mailing list  
> > swift-evolution@swift.org  
> > [https://lists.swift.org/mailman/listinfo/swift-evolution](https://lists.swift.org/mailman/listinfo/swift-evolution)

---

<div class="post-metadata">

**Author:** ![hartbit](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hartbit/32/738_2.png) [@hartbit](https://forums.swift.org/u/hartbit)\
**Post date:** [April 18, 2016, 6:04pm UTC](https://forums.swift.org/t/accepted-se-0064-referencing-the-objective-c-selector-of-property-getters-and-setters/2199/5 "2016-04-18T18:04:59Z")

</div>

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.

> In the spirit of taking my lumps for not speaking up when asked to do so, was there any discussion that considered:
> 
> &nbsp;&nbsp;&nbsp;let firstNameGetter = #selector(get: Person.firstName)  
> &nbsp;&nbsp;&nbsp;let firstNameSetter = #selector(set: Person.firstName)
> 
> in lieu of the accepted:
> 
> &nbsp;&nbsp;&nbsp;let firstNameGetter = #selector(getter: Person.firstName)  
> &nbsp;&nbsp;&nbsp;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.

---

<div class="post-metadata">

**Author:** ![jtbandes](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jtbandes/32/463_2.png) [@jtbandes](https://forums.swift.org/u/jtbandes)\
**Post date:** [April 15, 2016, 4:43pm UTC](https://forums.swift.org/t/accepted-se-0064-referencing-the-objective-c-selector-of-property-getters-and-setters/2199/6 "2016-04-15T16:43:40Z")

</div>

[http://apple.github.io/swift-internals/api-design-guidelines/](http://apple.github.io/swift-internals/api-design-guidelines/)

It's a matter of interpretation, but:

&nbsp;&nbsp;&nbsp;&nbsp;"Prefer method and function names that make use sites form grammatical  
English phrases."

Maybe I'm missing something, but I can't figure out how to read  
#selector(setter: Person.name). My second suggestion reads clearly as "the  
selector for setting Person.name".

Jacob

> **···**
>
> On Fri, Apr 15, 2016 at 5:03 AM, David Hart \<david@hartbit.com\> wrote:
> 
> > Why? What guideline are you referencing?
> > 
> > On 15 Apr 2016, at 09:53, Jacob Bandes-Storch via swift-evolution \< \> swift-evolution@swift.org\> wrote:
> > 
> > Was the syntax fully bikeshedded by the core team before acceptance?  
> > Perusing the API guidelines, one could also imagine:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;#selector(setting: Person.name)  
> > &nbsp;&nbsp;&nbsp;&nbsp;#selector(forSetting: Person.name)
> > 
> > On Thu, Apr 14, 2016 at 3:58 PM, Douglas Gregor via swift-evolution \< \> swift-evolution@swift.org\> wrote:
> > 
> > > Proposal link:  
> > > [https://github.com/apple/swift-evolution/blob/master/proposals/0064-property-selectors.md](https://github.com/apple/swift-evolution/blob/master/proposals/0064-property-selectors.md)
> > > 
> > > Hello Swift Community,
> > > 
> > > The review of SE-0064 "Referencing the Objective-C selector of property  
> > > getters and setters” ran from April 7...12, 2016. The proposal is  
> > > \*accepted\*. Feedback was light but positive, with many considering this  
> > > to effectively be an obviously-missing piece of the #selector proposal (  
> > > SE-0022  
> > > \<[https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md&gt](https://github.com/apple/swift-evolution/blob/master/proposals/0022-objc-selectors.md&gt);  
> > > ).
> > > 
> > > We welcome an implementation of this proposal. I’ve filed a ticket at
> > > 
> > > [[SR-1239] Implement SE-0064: Referencing the Objective-C selector of property getters and setters · Issue #43847 · apple/swift · GitHub](https://bugs.swift.org/browse/SR-1239)
> > > 
> > > to track the implementation.
> > > 
> > > - Doug
> > > 
> > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > > swift-evolution mailing list  
> > > swift-evolution@swift.org  
> > > [https://lists.swift.org/mailman/listinfo/swift-evolution](https://lists.swift.org/mailman/listinfo/swift-evolution)
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-evolution mailing list  
> > swift-evolution@swift.org  
> > [https://lists.swift.org/mailman/listinfo/swift-evolution](https://lists.swift.org/mailman/listinfo/swift-evolution)

---

<div class="post-metadata">

**Author:** ![Robert\_Schwalbe1](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Schwalbe1](https://forums.swift.org/u/Robert_Schwalbe1)\
**Post date:** [April 18, 2016, 11:11pm UTC](https://forums.swift.org/t/accepted-se-0064-referencing-the-objective-c-selector-of-property-getters-and-setters/2199/7 "2016-04-18T23:11:20Z")

</div>

> 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:
> > 
> > &nbsp;&nbsp;let firstNameGetter = #selector(get: Person.firstName)  
> > &nbsp;&nbsp;let firstNameSetter = #selector(set: Person.firstName)
> > 
> > in lieu of the accepted:
> > 
> > &nbsp;&nbsp;let firstNameGetter = #selector(getter: Person.firstName)  
> > &nbsp;&nbsp;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.

---

<div class="post-metadata">

**Author:** ![Douglas\_Gregor](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/douglas_gregor/32/1362_2.png) [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Post date:** [April 19, 2016, 1:45am UTC](https://forums.swift.org/t/accepted-se-0064-referencing-the-objective-c-selector-of-property-getters-and-setters/2199/8 "2016-04-19T01:45:06Z")

</div>

> > 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”.

Objective-C's @property syntax uses "getter" and "setter" to name the getter and setter selectors, and that's the information being extracted by this Swift expression.

&nbsp;&nbsp;- Doug

> **···**
>
> Sent from my iPhone  
> On Apr 18, 2016, at 4:11 PM, Robert Schwalbe via swift-evolution \<swift-evolution@swift.org\> wrote:
> 
> > > > 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.  
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > swift-evolution mailing list  
> > swift-evolution@swift.org  
> > [https://lists.swift.org/mailman/listinfo/swift-evolution](https://lists.swift.org/mailman/listinfo/swift-evolution)
