<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 26, 2016, at 9:25 PM, Austin Zheng via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">```</div><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">myPerson.typedReadWriteProperty&lt;Int&gt;("age")?.set(30)</div><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">try myPerson.allNamedProperties["age"]?.set(30)</div><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">```</div><br class="Apple-interchange-newline"></div></blockquote></div><br class=""><div class="">Can you elaborate on what this API would be used for? &nbsp;KVC? For instance, I played with Mirror the other day and my code to get a value given the property name looked more like this:</div><div class=""><br class=""></div><div class="">let age = myPerson.value(forKey:”age”) as! Int</div><div class=""><br class=""></div><div class="">And this is what I did:</div><div class=""><br class=""></div><div class="">// KVC stands for key-value-coding… but I only know how to get values. &nbsp;I don’t know how to set values</div><div class=""><br class=""></div><div class=""><div class="">protocol KVC {</div><div class="">&nbsp; &nbsp;func value(forKey key: String) -&gt; Any!</div><div class="">}</div><div class=""><br class=""></div><div class="">// Default implementation</div><div class="">extension KVC {</div><div class="">&nbsp; &nbsp;func value(forKey key: String) -&gt; Any! {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;let aMirror = Mirror(reflecting:self)</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;for case let (label?, value) in aMirror.children {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if label == key {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return value</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;return nil</div><div class="">&nbsp; &nbsp;}</div><div class="">}</div><div class=""><br class=""></div><div class="">public struct Person : KVC {</div><div class="">&nbsp; &nbsp;let firstName: String</div><div class="">&nbsp; &nbsp;let lastName: String</div><div class="">&nbsp; &nbsp;let age: Int</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp;func fullName() -&gt; String {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;return "\(firstName) \(lastName)"</div><div class="">&nbsp; &nbsp;}</div><div class="">}</div><div class=""><br class=""></div><div class="">let aPerson = Person(firstName:"John", lastName:"Doe", age:48)</div><div class=""><br class=""></div><div class="">// It works for stored properties</div><div class="">let lastName = aPerson.value(forKey:"lastName") as! String</div><div class="">print("Last name is \(lastName)")</div><div class=""><br class=""></div><div class="">// It does not work for instance methods, i.e. fullName is not a stored property</div><div class="">let fullName = aPerson.value(forKey:"fullName")</div><div class="">if fullName != nil {</div><div class="">&nbsp; &nbsp;print("Full name is \(fullName)")</div><div class="">} else {</div><div class="">&nbsp; &nbsp;print("Unable to get fullName via KVC")</div><div class="">}</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>