<div dir="ltr">+1. This definitely matches my real-world use of boolean properties across both languages.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div style="font-family:Helvetica"><br></div><div style="font-family:Helvetica">Jeff Kelley</div><div style="font-family:Helvetica"><br></div><div style="font-family:Helvetica"><a href="mailto:SlaunchaMan@gmail.com" style="color:rgb(17,85,204)" target="_blank">SlaunchaMan@gmail.com</a> | <a href="https://twitter.com/SlaunchaMan" style="color:rgb(17,85,204)" target="_blank">@SlaunchaMan</a> | <a href="http://jeffkelley.org/" style="color:rgb(17,85,204)" target="_blank">jeffkelley.org</a></div></div></div></div>
<br><div class="gmail_quote">On Tue, Feb 23, 2016 at 4:00 PM, Douglas Gregor via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi all,<div><br></div><div>The Swift API guidelines state that Boolean properties should reflect assertions about the receiver, so in Swift one would expect:</div><div><br></div><div><span style="white-space:pre-wrap">        </span>class Foo {</div><div><span style="white-space:pre-wrap">        </span> var isEnabled: Bool // good</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div>rather than</div><div><br></div><div><span style="white-space:pre-wrap">        </span>class Foo {</div><div><span style="white-space:pre-wrap">        </span> var enabled: Bool // not Swifty</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div>When the property is @objc, e.g.,</div><div><br></div><div><span style="white-space:pre-wrap">        </span>class Foo : NSObject {</div><div><span style="white-space:pre-wrap">        </span> @objc var isEnabled: Bool</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div>The resulting Objective-C property doesn’t follow the <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-BAJGIIJE" target="_blank">Cocoa guidelines for Objective-C</a>:</div><div><br></div><div><span style="white-space:pre-wrap">        </span>@property (readwrite,nonatomic) BOOL isEnabled;</div><div><br></div><div>because those guidelines state that properties do not use the “is” prefix.</div><div><br></div><div>My proposal is to strip the “is” prefix from the Objective-C name, but leave it off the getter, e.g.,</div><div><br></div><div><span style="white-space:pre-wrap">        </span>@property (readwrite,nonatomic,getter=isEnabled) BOOL enabled;</div><div><br></div><div>The change would have no effect on the Swift name; it will only affect the Objective-C property name and setter name.</div><div><br></div><div>Thoughts?</div><div><br></div><div><span style="white-space:pre-wrap">        </span>- Doug</div><div><br></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>