<div dir="ltr">Thank you all for your input, I have revised the proposal to merely &quot;go the other way&quot;.  It will allow Swift API developers to make enum strings available to objective-c as global strings.<div><br></div><div><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md">https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md</a><br></div><div><br></div><div><div style="box-sizing:border-box;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:14px"><div style="box-sizing:border-box"><div id="inbox-js-repo-pjax-container" style="box-sizing:border-box"><div class="inbox-container inbox-new-discussion-timeline inbox-experiment-repo-nav" style="box-sizing:border-box;width:980px;margin-right:auto;margin-left:auto"><div class="inbox-repository-content" style="box-sizing:border-box"><div class="inbox-file" style="box-sizing:border-box;margin-top:16px;margin-bottom:16px;border:1px solid rgb(221,221,221);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><div id="inbox-readme" class="inbox-readme inbox-blob inbox-instapaper_body" style="box-sizing:border-box"><h1 style="box-sizing:border-box;font-size:2em;margin:0px 0px 16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)">Swift Enum strings ported to Objective-c</h1><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px"><li style="box-sizing:border-box">Proposal: <a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-filename.md" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">SE-NNNN</a></li><li style="box-sizing:border-box;margin-top:0.25em">Authors: <a href="https://github.com/wh1pch81n" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">Derrick Ho</a></li><li style="box-sizing:border-box;margin-top:0.25em">Review Manager: TBD</li><li style="box-sizing:border-box;margin-top:0.25em">Status: <span style="box-sizing:border-box;font-weight:600">Awaiting review</span></li></ul><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px"><em style="box-sizing:border-box">During the review process, add the following fields as needed:</em></p><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px"><li style="box-sizing:border-box">Decision Notes: <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20161114/028950.html" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">Rationale</a></li><li style="box-sizing:border-box;margin-top:0.25em">Previous Proposal: <a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/0033-import-objc-constants.md" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">SE-0033</a></li></ul><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="inbox-user-content-introduction" class="inbox-anchor" href="https://github.com/wh1pch81n/swift-evolution/tree/swift-enum-objc#introduction" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Introduction</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">We should allow swift-enum-strings and swift-struct-strings to be ported to objective-c. We can use the following notation:</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">@objc enum Planets: String { case Mercury }</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">struct Food { @objc public static let hamburger = Food(rawValue: &quot;hamburger&quot;) }</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">Swift-evolution thread: <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20161114/028950.html" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">Discussion</a> <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170220/032656.html" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">Discussion</a></p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="inbox-user-content-motivation" class="inbox-anchor" href="https://github.com/wh1pch81n/swift-evolution/tree/swift-enum-objc#motivation" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Motivation</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">NS_STRING_ENUM and NS_EXSTENSIBLE_STRING_ENUM are annotations that you can add to an objective-c global string. The annotations will make swift interpret the objective-c global strings as structs. However, there does not exist any way to go the other way around. Anyone that wants global strings to be available to objective-c and swift will need to make them in Objective-c. We should give API authors the ability to make global strings in the swift language by allowing enums to be converted to NSString&#39;s in objective-c</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="inbox-user-content-proposed-solution" class="inbox-anchor" href="https://github.com/wh1pch81n/swift-evolution/tree/swift-enum-objc#proposed-solution" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Proposed solution</h2><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding:0px;margin:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal">// `@objc` and `String` can be applied to an enum to make it available to objective-c:
//
@objc
public enum Food: String {
   case Calamari 
   case Fish


// This can be ported over to Objective-c as an objective-c class

typedef NSString *_Nonnull Food;
static Food const FoodCalamari = @&quot;Calamari&quot;;
static Food const FoodFish = @&quot;Fish&quot;;
</code></pre><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding:0px;margin:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal">// `@objc` and `String` can be applied to a struct to make it available to objective-c:
//

@objc
public struct Planets: String {
  public let rawValue: String //&lt;- This should be implicit and the user should not need to add it
  init(rawValue: String) { self.rawValue = rawValue } //&lt;- This should be implicit and the user should not need to add it

  @objc public static let Earth = Planets(rawValue: &quot;Earth&quot;) //&lt;- user defines these
  @objc public static let Venus = Planets(rawValue: &quot;Venus&quot;) //&lt;- user defines these
}

// This can be ported over to objective-c as a class

typedef NSString *_Nonnull Planets;
Planets const PlanetsEarth = @&quot;Earth&quot;;
Planets const PlanetsVenus = @&quot;Venus&quot;;
</code></pre><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="inbox-user-content-detailed-design" class="inbox-anchor" href="https://github.com/wh1pch81n/swift-evolution/tree/swift-enum-objc#detailed-design" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Detailed design</h2><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25"><a id="inbox-user-content-swift-string-enum---casestring-translations" class="inbox-anchor" href="https://github.com/wh1pch81n/swift-evolution/tree/swift-enum-objc#swift-string-enum---casestring-translations" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>swift-string-enum - case/string translations</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">A swift-enum-string, is created with cases and it has an implicit string value based on the name of the case. The user may also add a name that does not equal the name of the case.</p><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding:0px;margin:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal">// Swift
@objc
public enum Food: String {
  case Calamari 
  case Fish = &quot;Flounder&quot; //&lt;-- User wants Fish to be Flounder


// Objective-c
// The variable will &lt;name_of_enum&gt;&lt;name_of_case&gt;.  And should follow camel-case rules.
typedef NSString *_Nonnull Food;
static Food const FoodCalamari = @&quot;Calamari&quot;;
static Food const FoodFish = @&quot;Flounder&quot;;
</code></pre><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25"><a id="inbox-user-content-swift-struct-string---string-translations" class="inbox-anchor" href="https://github.com/wh1pch81n/swift-evolution/tree/swift-enum-objc#swift-struct-string---string-translations" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>swift-struct-string - string translations</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">A swift-struct-string needs to be marked with <code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">@objc</code> and inherit from <code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">String</code> to be available to objective-c. A property must be marked with @objc to be made available to objective-c.</p><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding:0px;margin:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal">// Swift
@objc
struct Planet {
  @objc public static let Earth = Planet(rawValue: &quot;Earth&quot;)
}

// Objective-c
typedef NSString *_Nonnull Planet;
static Planet const PlanetEarth = @&quot;Earth&quot;;
</code></pre><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="inbox-user-content-source-compatibility" class="inbox-anchor" href="https://github.com/wh1pch81n/swift-evolution/tree/swift-enum-objc#source-compatibility" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Source compatibility</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">This will be an additive feature and will not break anything existing.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="inbox-user-content-alternatives-considered" class="inbox-anchor" href="https://github.com/wh1pch81n/swift-evolution/tree/swift-enum-objc#alternatives-considered" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Alternatives considered</h2><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:0px"><li style="box-sizing:border-box">Don&#39;t change anything.</li></ul></div></div></div></div></div></div></div><div class="inbox-container inbox-site-footer-container" style="box-sizing:border-box;width:980px;margin-right:auto;margin-left:auto;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:14px"><div class="inbox-site-footer" style="box-sizing:border-box;padding-top:40px;padding-bottom:40px;margin-top:40px;font-size:12px;line-height:1.5;color:rgb(88,96,105);border-top-width:1px;border-top-style:solid;border-top-color:rgb(234,236,239)"></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Feb 27, 2017 at 5:35 PM Zach Waldowski via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u class="gmail_msg"></u>




<div class="gmail_msg"><div style="font-family:Arial" class="gmail_msg">I don&#39;t understand the question. It should turn it into a group of NSStrings prefixed by a common name. That&#39;s how they&#39;re imported from Objective-C, stripped of their common prefix.<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div id="m_4526262349455146161sig40804545" class="gmail_msg"><div class="m_4526262349455146161signature gmail_msg"><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif">Sincerely,</span><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif"></span><br class="gmail_msg"></div>
<div class="m_4526262349455146161signature gmail_msg"><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif">  Zachary Waldowski</span><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif"></span><br class="gmail_msg"></div>
<div class="m_4526262349455146161signature gmail_msg"><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif">  </span><a href="mailto:zach@waldowski.me" class="gmail_msg" target="_blank"><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif">zach@waldowski.me</span></a><br class="gmail_msg"></div>
</div></div><div class="gmail_msg">
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg">On Mon, Feb 27, 2017, at 05:02 PM, Derrick Ho via swift-evolution wrote:<br class="gmail_msg"></div>
<blockquote type="cite" class="gmail_msg"><div style="font-family:Arial" class="gmail_msg">NS_EXTENSIBLE_STRING_ENUM <br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">Turns a groups of NSStrings into a struct.<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">What do you suggest for the reverse?<br class="gmail_msg"></div>
<div class="gmail_msg"><div dir="ltr" class="gmail_msg">On Mon, Feb 27, 2017 at 4:39 PM Zach Waldowski via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex" class="gmail_msg"><div style="font-family:Arial" class="gmail_msg"><u class="gmail_msg"></u><br class="gmail_msg"></div>
<div class="gmail_msg"><div style="font-family:Arial" class="gmail_msg">-1 as written due to the impedance mismatch with importing NS_STRING_ENUM and NS_EXTENSIBLE_STRING_ENUM. Exporting to Objective-C should export a typedef and several constants, not a class. Exporting generated accessors to Objective-C is unnecessary as you have -isEqual: and -hashValue on NSString over there.<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">I&#39;m not sure how technically feasible it is to identify &quot;a struct with a single field conforming to RawRepresentable&quot; to make it compatible with @objc, though I&#39;m not really a compiler person.<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">Other than that, I like the idea. I don&#39;t believe any of the annotations to make Objective-C code better in Swift should be one-way.<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg"><div class="gmail_msg"><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif">Sincerely,</span><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif"></span><br class="gmail_msg"></div>
<div class="gmail_msg"><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif">  Zachary Waldowski</span><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif"></span><br class="gmail_msg"></div>
<div class="gmail_msg"><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif">  </span><a href="mailto:zach@waldowski.me" class="gmail_msg" target="_blank"><span class="m_4526262349455146161font gmail_msg" style="font-family:arial,sans-serif,sans-serif">zach@waldowski.me</span></a><br class="gmail_msg"></div>
</div>
</div>
<div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg">On Sun, Feb 26, 2017, at 01:21 PM, Derrick Ho via swift-evolution wrote:<br class="gmail_msg"></div>
<blockquote type="cite" class="gmail_msg"><div dir="ltr" class="gmail_msg"><div style="font-family:Arial" class="gmail_msg">I updated my <a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md" class="gmail_msg" target="_blank">proposal</a> to reflect the community&#39;s desire to build on @objc instead of adding a new attribute @objcstring.<br class="gmail_msg"></div>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg">I&#39;ve included it below for convenience:<br class="gmail_msg"></div>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg"><h1 style="margin-top:0px;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg">Swift Enum strings ported to Objective-c<br class="gmail_msg"></h1><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px" class="gmail_msg"><li class="gmail_msg">Proposal: <a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-filename.md" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" class="gmail_msg" target="_blank">SE-NNNN</a><br class="gmail_msg"></li><li style="margin-top:0.25em" class="gmail_msg">Authors: <a href="https://github.com/wh1pch81n" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" class="gmail_msg" target="_blank">Derrick Ho</a><br class="gmail_msg"></li><li style="margin-top:0.25em" class="gmail_msg">Review Manager: TBD<br class="gmail_msg"></li><li style="margin-top:0.25em" class="gmail_msg">Status: <span style="font-weight:600" class="gmail_msg">Awaiting review</span><br class="gmail_msg"></li></ul><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px"><i class="gmail_msg">During the review process, add the following fields as needed:</i></span></span></span><br class="gmail_msg"></p><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px" class="gmail_msg"><li class="gmail_msg">Decision Notes: <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20161114/028950.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" class="gmail_msg" target="_blank">Rationale</a><br class="gmail_msg"></li><li style="margin-top:0.25em" class="gmail_msg">Previous Proposal: <a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/0033-import-objc-constants.md" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" class="gmail_msg" target="_blank">SE-0033</a><br class="gmail_msg"></li></ul><h2 style="margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#introduction" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>Introduction<br class="gmail_msg"></h2><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">We should allow swift-enum-strings and swift-struct-strings to be bridged to objective-c. We can use the following notation:</span></span></span><br class="gmail_msg"></p><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">@objc enum Planets: String { case Mercury }</span></span></span><br class="gmail_msg"></p><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">@objc struct Food: String { public static let hamburger = Food(rawValue: &quot;hamburger&quot;) }</span></span></span><br class="gmail_msg"></p><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">Creating a bridgable version will allow objective-c to enjoy some of the benefits that swift enjoys. </span></span></span><br class="gmail_msg"></p><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">Swift-evolution thread: <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20161114/028950.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" class="gmail_msg" target="_blank">Discussion</a> <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170220/032656.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" class="gmail_msg" target="_blank">Discussion</a></span></span></span><br class="gmail_msg"></p><h2 style="margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#motivation" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>Motivation<br class="gmail_msg"></h2><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">NS_STRING_ENUM and NS_EXSTENSIBLE_STRING_ENUM are annotations that you can add to an objective-c global string. The annotations will make swift interpret the objective-c global strings as enum and structs respectively in theory. But it actually <a href="https://bugs.swift.org/browse/SR-3146" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" class="gmail_msg" target="_blank">doesn&#39;t ever create enums</a>.</span></span></span><br class="gmail_msg"></p><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">The problem seems to stem from the conversion from objc to swift. It might be more fruitful to make a conversion from swift to objc.</span></span></span><br class="gmail_msg"></p><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">However, what if we take it a step further? Turning a swift-string-enum into a bunch of global NSStrings really limits its power. There are many classes written by apple that are structs in swift but become classes in objective-c (i.e. String becomes NSString, Date becomes NSDate, Array becomes NSArray, etc). There is a special bridging mechanism that allows this to be possible. I think we should expand on that.</span></span></span><br class="gmail_msg"></p><h2 style="margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#proposed-solution" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>Proposed solution<br class="gmail_msg"></h2><pre style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px;overflow-x:auto;overflow-y:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:initial;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;display:inline;overflow-x:visible;overflow-y:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">// `@objc` and `String` can be applied to an enum to make it available to objective-c:
//
@objc
public enum Food: String {
   case Calamari 
   case Fish


// This can be ported over to Objective-c as an objective-c class

@interface Food: NSObject

@property (readonly) NSString *_Nonnull rawValue;

- (instancetype _Nullable)initWithRawValue:(NSString *_Nonnull)rawValue;

+ (instanceType _Nonnull)Calamari;
+ (instanceType _Nonnull)Fish;

@end

</code><br class="gmail_msg"></pre><pre style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px;overflow-x:auto;overflow-y:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:initial;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;display:inline;overflow-x:visible;overflow-y:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">// `@objc` and `String` can be applied to a struct to make it available to objective-c:
//

@objc
public struct Planets: String {
  public let rawValue: String //&lt;- This should be implicit and the user should not need to add it
  init(rawValue: String) { self.rawValue = rawValue } //&lt;- This should be implicit and the user should not need to add it

  public static let Earth = Planets(rawValue: &quot;Earth&quot;) //&lt;- user defines these
  public static let Venus = Planets(rawValue: &quot;Venus&quot;) //&lt;- user defines these
}

// This can be ported over to objective-c as a class

@interface Planets: NSObject 
- (instancetype _Nonnull)initWithRawValue:(NSString *_Nonnull)rawValue;

+ (instancetype)Earth;
+ (instancetype)Venus;
@end
</code><br class="gmail_msg"></pre><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">The difference between a swift-enum-string and a swift-struct-string is that swift-enum-string provides a failable initializer while swift-struct-string provides a non-failable initializer.</span></span></span><br class="gmail_msg"></p><h2 style="margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#detailed-design" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>Detailed design<br class="gmail_msg"></h2><h3 style="margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#swift-string-enum---casestring-translations" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>swift-string-enum - case/string translations<br class="gmail_msg"></h3><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">A swift-enum-string, is created with cases and it has an implicit string value based on the name of the case. The user may also add a name that does not equal the name of the case.</span></span></span><br class="gmail_msg"></p><pre style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px;overflow-x:auto;overflow-y:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:initial;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;display:inline;overflow-x:visible;overflow-y:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">// Swift
@objc
public enum Food: String {
  case Calamari 
  case Fish = &quot;Flounder&quot; //&lt;-- User wants Fish to be Flounder


// Objective-c

@interface Food: NSObject

@property (readonly) NSString *_Nonnull rawValue;

+ (instanceType _Nonnull)Calamari;
+ (instanceType _Nonnull)Fish;

@end

@implementation Food
+ (instanceType _Nonnull)Calamari { return [[Food alloc] initWithRawValue:@&quot;Calimari&quot;]; }
+ (instanceType _Nonnull)Fish { return [[Food alloc] initWithRawValue:@&quot;Flounder&quot;]; } //&lt;-- Fisher contains Flounder
@end
</code><br class="gmail_msg"></pre><h3 style="margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#swift-string-enum---failable-initializer" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>swift-string-enum - failable initializer<br class="gmail_msg"></h3><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">A swift-enum-string has the ability to be initialized with a string. If the string matches one of the possible cases, then it returns it, otherwise it will return nil. This feature might be implemented as a dictionary or some other means that gets the same results; Below is my suggestion.</span></span></span><br class="gmail_msg"></p><pre style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px;overflow-x:auto;overflow-y:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:initial;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;display:inline;overflow-x:visible;overflow-y:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">// Assuming this swift implementation
@objc
public enum Food: String {
  case Calamari 
  case Fish = &quot;Flounder&quot; //&lt;-- User wants Fish to be Flounder


// The objective-c failable initializer may look like this.
@implementation Food

- (instancetype _Nullable)initWithRawValue:(NSString *_Nonnull)rawValue {
  static NSDictionary &lt;NSString *, NSString *&gt;*states;
  if (!states) {
    // A dictionary where the KEYs are the acceptable rawValue&#39;s and the VALUE are empty strings
    states = @{
      @&quot;Calimari&quot; : @&quot;&quot;,
      @&quot;Flounder&quot; : @&quot;&quot;
    }
  }

  if ((self = [super init])) {
    if (states[rawValue]) {
      _rawValue = rawValue
      return self;
    }
  }
  return nil;
}

@end
</code><br class="gmail_msg"></pre><h3 style="margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#swift-string-enum---methods" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>swift-string-enum - methods<br class="gmail_msg"></h3><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">swift enums allow methods to be defined. If you mark a method with <code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;padding-top:0.2em;padding-right:0px;padding-bottom:0.2em;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">@objc</code> it should be made available to objective-c. </span></span></span><br class="gmail_msg"></p><pre style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px;overflow-x:auto;overflow-y:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:initial;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;display:inline;overflow-x:visible;overflow-y:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">// Swift
@objc
public enum Food: String {
  case Calamari 
  case Fish

  @objc func price() -&gt; Double {
    // ...
  }


// Objective-c
@interface Food: NSObject 
// ...

- (Double)price;

// ...
@end
</code><br class="gmail_msg"></pre><h3 style="margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#swift-struct-string---string-translations" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>swift-struct-string - string translations<br class="gmail_msg"></h3><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">A swift-struct-string needs to be marked with <code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;padding-top:0.2em;padding-right:0px;padding-bottom:0.2em;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">@objc</code> and inherit from <code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;padding-top:0.2em;padding-right:0px;padding-bottom:0.2em;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code> to bridge to objective-c. A property or method must be marked with @objc to be made available to objective-c.</span></span></span><br class="gmail_msg"></p><pre style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px;overflow-x:auto;overflow-y:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:initial;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;display:inline;overflow-x:visible;overflow-y:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">// Swift
@objc
struct Planet {
  @objc public static let Earth = Planet(rawValue: &quot;Earth&quot;)

  @objc public func distanceFromSun() -&gt; Double { ... }
}

// Objective-c
@interface Planet
+ (instancetype _Nonnull)Earth;
+ (Double)distanceFromSun;
@end
</code><br class="gmail_msg"></pre><h3 style="margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#swift-struct-string---non-failable-initializer" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>swift-struct-string - non-failable initializer<br class="gmail_msg"></h3><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">The swift-struct-string initializer should not be failable and will accept any string value</span></span></span><br class="gmail_msg"></p><pre style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px;overflow-x:auto;overflow-y:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:initial;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;display:inline;overflow-x:visible;overflow-y:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">@implementation Planet
- (instancetype _Nonnull)initWithRawValue:(NSString *)rawValue {
  if ((self = [super init])) {
    _rawValue = rawValue;
  }

  return self;
}
@end
</code><br class="gmail_msg"></pre><h3 style="margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#swift-struct-string---extension" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>swift-struct-string - extension<br class="gmail_msg"></h3><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">One of the key attributes of an extensible string enum is that it can be extended. This should produce something available to objective-c. The original definition of Planet needs to have been marked with @objc.</span></span></span><br class="gmail_msg"></p><pre style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px;overflow-x:auto;overflow-y:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:initial;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;display:inline;overflow-x:visible;overflow-y:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">// Swift
extension Planet {
  @objc public static let Pluto = Planet(rawValue: &quot;Pluto&quot;)
}

// Objective-c

@interface Planet (extention_1)
- (instancetype _Nonnull)Pluto;
@end

@implementation Planet (extention_1)
- (instancetype _Nonnull)Pluto {
  return [[Planet alloc] initWithRawValue:@&quot;Pluto&quot;];
}
@end
</code><br class="gmail_msg"></pre><h3 style="margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#swift-string-enum--swift-struct-string---equalityhashrawvalue" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>swift-string-enum &amp;&amp; swift-struct-string - equality/hash/rawValue<br class="gmail_msg"></h3><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">When an enum or struct is marked with <code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;padding-top:0.2em;padding-right:0px;padding-bottom:0.2em;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">@objc</code> and <code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;padding-top:0.2em;padding-right:0px;padding-bottom:0.2em;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">String</code>, the objective-c class that is produced should have its equality/hash methods and rawValue property implicitly be implemented. The user should not need to implement these on his/her own. </span></span></span><br class="gmail_msg"></p><pre style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px;overflow-x:auto;overflow-y:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:initial;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;display:inline;overflow-x:visible;overflow-y:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">@implementation Food

- (instancetype)rawValue { return _rawValue; }

- (NSUInteger)hash {
  return [[self rawValue] hash];
}

- (BOOL)isEqual:(id)object {
  if (self == object) { return YES }
  if (![object isKindOfClass:[Food class]]) { return NO; }

  return [self.rawValue isEqualToString:((Food *)object).rawValue];
}

@end
</code><br class="gmail_msg"></pre><h2 style="margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#objective-c-name" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>Objective-c name<br class="gmail_msg"></h2><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">In the above examples, the objective-c name of the class and the swift name of the class were the same. If this causes a naming conflict then the objective-c name could be Prefixed with ENUM.</span></span></span><br class="gmail_msg"></p><pre style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px;overflow-x:auto;overflow-y:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:initial;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;display:inline;overflow-x:visible;overflow-y:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">// Swift
@objc
enum Planet: String { ... }

// Objective-c
@interface ENUMPlanet
@end
</code><br class="gmail_msg"></pre><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">The programmer should still be able to add their own name by specifying it as an argument.</span></span></span><br class="gmail_msg"></p><pre style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding-top:16px;padding-right:16px;padding-bottom:16px;padding-left:16px;overflow-x:auto;overflow-y:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,menlo,courier,monospace;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:initial;border-right-style:initial;border-bottom-style:initial;border-left-style:initial;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;display:inline;overflow-x:visible;overflow-y:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">// Swift
@objc(CustomPlanet)
enum Planet { ... }

// Objective-c
@interface CustomPlanet
@end
</code><br class="gmail_msg"></pre><h2 style="margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#source-compatibility" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>Source compatibility<br class="gmail_msg"></h2><p style="margin-top:0px;margin-bottom:16px" class="gmail_msg"><span class="m_4526262349455146161colour gmail_msg" style="color:rgb(51,51,51)"><span class="m_4526262349455146161font gmail_msg" style="font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span class="m_4526262349455146161size gmail_msg" style="font-size:16px">This will be an additive feature and will not break anything existing.</span></span></span><br class="gmail_msg"></p><h2 style="margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md#alternatives-considered" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" class="gmail_msg" target="_blank"></a>Alternatives considered<br class="gmail_msg"></h2><ul style="padding-left:2em;margin-top:0px;color:rgb(51,51,51);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px;margin-bottom:0px" class="gmail_msg"><li class="gmail_msg"><p style="margin-top:16px;margin-bottom:16px" class="gmail_msg">Implement a swift class that implements the above described behviors.<br class="gmail_msg"></p></li><li style="margin-top:0.25em" class="gmail_msg"><p style="margin-top:16px;margin-bottom:16px" class="gmail_msg">Don&#39;t change anything.<br class="gmail_msg"></p></li></ul></div>
</div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg"><div dir="ltr" class="gmail_msg">On Tue, Feb 21, 2017 at 6:09 PM Derrick Ho &lt;<a href="mailto:wh1pch81n@gmail.com" class="gmail_msg" target="_blank">wh1pch81n@gmail.com</a>&gt; wrote:<br class="gmail_msg"></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex" class="gmail_msg"><div style="font-family:Arial" class="gmail_msg">True. <br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">In my proposal I mention how NS_STRING_ENUM  doesn&#39;t produce an swift enum.<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">So one solution is to merely &quot;go the other way&quot; which would produce what Kevin N. suggested. <br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">Is it not odd that that the objc version is so different from the swift version?<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">Would it not be better to offer a somewhat similar API experience between the two languages?<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">@objcstring would &quot;promote&quot; the swift enum to an objective-c class to make the API experience similar.<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">I understand that maybe @objcstring is too niche to get its own annotation.  Instead @objc should become more powerful.<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">I think @objc should make an enum become a class with swift-enum like abilities.  This would allow enum functions to be bridged over to objective-c as well.<br class="gmail_msg"></div>
<div class="gmail_msg"><div dir="ltr" class="gmail_msg">On Tue, Feb 21, 2017 at 1:32 PM Michael Ilseman &lt;<a href="mailto:milseman@apple.com" class="gmail_msg" target="_blank">milseman@apple.com</a>&gt; wrote:<br class="gmail_msg"></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex" class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">A quick note addressing a misconception that you’ll want to clean up for a formal proposal:<br class="gmail_msg"></div>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg">NS_[EXTENSIBLE_]STRING_ENUMs both generate Swift structs, the difference is only in the explicitness of the rawValue initializer. To use the “other direction” analogy, you’d similarly want them to apply for rawValue-ed structs alone. The reasons are the same: only the structs are layout-compatible because enums are integers.<br class="gmail_msg"></div>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg">Once you go down this route, perhaps it doesn’t make sense to annotate the struct decls themselves anymore. Maybe you just want more @objc control over bridging the types. For example, maybe you want to introduce a feature so that static members that are layout-compatible with String are bridged as global strings with the supplied name.<br class="gmail_msg"></div>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg"><br class="gmail_msg"></div>
<div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><br class="gmail_msg"></blockquote></div>
</div>
<div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Feb 20, 2017, at 4:07 PM, Derrick Ho via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"></div>
</blockquote></div>
</div>
<div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg">Swift should not forsake objective-c.  At least not when it comes enum strings.  Although swift enums are suppose to be swift only, I think we should add a new attribute to slightly relax that.  I think a good attribute would be @objcstring.<br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg"><br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg">By adding @objcstring, an objective-c exclusive class will be generated.<br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg"><br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg">@objcstring<br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg">enum Planet {<br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg">  case Jupiter<br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg">}<br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg"><br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg">I have written up a proposal with more details on what it would look for objective-c.<br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg"><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><a href="https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md" style="word-spacing:1px" class="gmail_msg" target="_blank">https://github.com/wh1pch81n/swift-evolution/blob/swift-enum-objc/proposals/NNNN-Swift-enum-strings-ported-to-Objective-c.md</a><br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg"><br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg">If no one objects to this proposal I&#39;ll submit it.<br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg"><br class="gmail_msg"></div>
<div style="color:rgb(49,49,49);word-spacing:1px" class="gmail_msg">**notes: I am reviving this discussion so that I may submit this for Swift 4 stage 2<br class="gmail_msg"></div>
</div>
</div>
</blockquote></div>
</div>
<div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div style="font-family:Arial" class="gmail_msg">_______________________________________________<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div>
</div>
</blockquote></div>
</div>
</blockquote></div>
</blockquote></div>
<div class="gmail_msg"><u class="gmail_msg">_______________________________________________</u><br class="gmail_msg"></div>
<div class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"></div>
<div class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"></div>
<div class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div>
</blockquote><div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
</div>
<div style="font-family:Arial" class="gmail_msg">_______________________________________________<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"> swift-evolution mailing list<br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"> <a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"></div>
<div style="font-family:Arial" class="gmail_msg"> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div>
</blockquote></div>
<div class="gmail_msg"><u class="gmail_msg">_______________________________________________</u><br class="gmail_msg"></div>
<div class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"></div>
<div class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"></div>
<div class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div>
</blockquote><div style="font-family:Arial" class="gmail_msg"><br class="gmail_msg"></div>
</div>

_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>