<html><head><meta http-equiv="Content-Type" content="text/html charset=gb2312"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><span style="color: rgb(51, 51, 51); font-family: inherit; font-size: 10pt; font-style: inherit;" class=""><br class=""></span></div><span style="color: rgb(51, 51, 51); font-family: inherit; font-size: 10pt; font-style: inherit;" class="">Hi all,</span><br class=""><div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><span class="" style="font-family: inherit; color: rgb(51, 51, 51); font-size: 10pt; font-style: inherit;">I </span><font color="#333333" face="Helvetica Neue" size="2" class="" style="font-family: 'Helvetica Neue';">want to discuss on a </font><span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue'; font-size: small;" class="">problem</span> about <span style="font-family: 'Helvetica Neue'; color: rgb(51, 51, 51); font-size: small;" class="">optional generic sub-typing.</span></div><div class=""><div class=""><br class=""></div><div class=""><div class="">This is my suggesion.</div><div class=""><br class=""></div></div><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">if B is subclass of A</div><div class="">Either<B,B> is subclass of Either<A,A>, Either<A,B>, Either<B,A></div><div class="">Either<B,A> is subclass of Either<A,A></div><div class=""><div class="">Either<A,B> is subclass of Either<A,A></div><div class=""><br class=""></div></div></div></div></div></div><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""></div><div class=""></div></div></div></div></div></blockquote></div><div class="">Why? Let¡¯s see an example code in a real project:</div><div class=""><br class=""></div><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="margin: 0px 0px 0px 6px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px 0px 0px 6px; line-height: normal; font-family: 'Helvetica Neue';" class=""><span style="color: rgb(51, 51, 51); font-family: inherit; font-size: 10pt; font-style: inherit;" class=""><br class=""></span></div><div style="margin: 0px 0px 0px 6px; line-height: normal; font-family: 'Helvetica Neue';" class=""><span style="color: rgb(51, 51, 51); font-family: inherit; font-size: 10pt; font-style: inherit;" class="">Here is a protocol type for some UIViewController,</span></div><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="dp-highlighter" style="box-sizing: border-box; padding: 1px 0px 0px; border: none; font-family: Consolas, 'Courier New', Courier, mono, serif; vertical-align: baseline; background-color: rgb(249, 249, 249); width: auto; overflow: visible; color: rgb(51, 51, 51); margin: 0px !important;"><div class="bar" style="box-sizing: border-box; margin: 0px; padding: 0px 0px 0px 45px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"></div></div><ol start="1" class="dp-j" style="box-sizing: border-box; padding: 0px; border: none; font-style: inherit; font-family: inherit; vertical-align: baseline; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">protocol SegueHandlerType { </span></li><li class="" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;"> var tableView: UITableView! { get } </span></li><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">} </span></li></ol></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><br class=""></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;">so the UITableViewController can conform to the protocal</span></div><div class="dp-highlighter" style="box-sizing: border-box; padding: 1px 0px 0px; border: none; font-family: Consolas, 'Courier New', Courier, mono, serif; vertical-align: baseline; background-color: rgb(249, 249, 249); width: auto; overflow: visible; color: rgb(51, 51, 51); margin: 0px !important;"><div class="bar" style="box-sizing: border-box; margin: 0px; padding: 0px 0px 0px 45px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"></div></div><ol start="1" class="dp-j" style="box-sizing: border-box; padding: 0px; border: none; font-style: inherit; font-family: inherit; vertical-align: baseline; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">extension UITableViewController : SegueHandlerType { </span></li><li class="" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">} </span></li></ol></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;"><br class="" style="box-sizing: border-box;"></span></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;">It's great!</span></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;">What if the tableView is a subclass UITableView?</span></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;">like:</span></div><div class="dp-highlighter" style="box-sizing: border-box; padding: 1px 0px 0px; border: none; font-family: Consolas, 'Courier New', Courier, mono, serif; vertical-align: baseline; background-color: rgb(249, 249, 249); width: auto; overflow: visible; color: rgb(51, 51, 51); margin: 0px !important;"><div class="bar" style="box-sizing: border-box; margin: 0px; padding: 0px 0px 0px 45px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"></div></div><ol start="1" class="dp-j" style="box-sizing: border-box; padding: 0px; border: none; font-style: inherit; font-family: inherit; vertical-align: baseline; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">class MyTableView : UITableView {</span></li><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">}</span></li><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;"><br class=""></span></li><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">MyTableViewController { </span></li><li class="" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;"> <span class="annotation" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; color: rgb(100, 100, 100); background-color: inherit; font-size: 9pt !important;">@IBOutlet</span><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;"> var tableView: MyTableView! </span></span></li><li class="" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">} </span></li></ol></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><br class=""></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-size: 10pt; font-family: inherit; vertical-align: baseline;">Then </span></div><div class="dp-highlighter" style="box-sizing: border-box; padding: 1px 0px 0px; border: none; font-family: Consolas, 'Courier New', Courier, mono, serif; vertical-align: baseline; background-color: rgb(249, 249, 249); width: auto; overflow: visible; color: rgb(51, 51, 51); margin: 0px !important;"><div class="bar" style="box-sizing: border-box; margin: 0px; padding: 0px 0px 0px 45px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"></div></div><ol start="1" class="dp-j" style="box-sizing: border-box; padding: 0px; border: none; font-style: inherit; font-family: inherit; vertical-align: baseline; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">extension MyTableViewController:SegueHandlerType { </span></li><li class="" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; background-color: rgb(248, 248, 248); height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;"> </span></li><li class="alt" style="box-sizing: border-box; border-left-width: 3px; border-style: none none none solid; border-left-color: rgb(255, 255, 255); font-style: inherit; font-size: 1em; font-family: inherit; vertical-align: baseline; line-height: 12pt; list-style: decimal-leading-zero outside; color: inherit; height: 12pt; position: relative; white-space: nowrap; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-style: inherit; vertical-align: baseline; background-color: inherit; font-size: 9pt !important;">} </span></li></ol></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; line-height: 1.4737em;"><span style="font-family: Helvetica; font-size: 12px;" class="">will trigger a compiler error.</span><br style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""> </span><br style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">So the Optional needs a subclass system.</span><br style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">Or to say, that the template system needs a subclass system.</span><br style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""> </span><br style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">Optional<UITableView> should be the super type of Optional<MyTableView></span><br style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">Array<UITableView> should be the super type of Array<MyTableView></span></div></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; font-size: 16px; font-family: 'Myriad Set Pro', 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; vertical-align: baseline; line-height: 1.4737em; color: rgb(51, 51, 51);"><br class=""></div><div class="" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; line-height: 1.4737em;"><font color="#333333" face="Myriad Set Pro, Lucida Grande, Helvetica Neue, Helvetica, Arial, Verdana, sans-serif" size="3" class=""><a href="https://forums.developer.apple.com/message/101646#101646" class="">https://forums.developer.apple.com/message/101646#101646</a></font></div></div></div></div></div></div><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"></div></div></div></div></div></blockquote></div><div class=""><br class=""></div><div class=""><div class=""><br class=""></div></div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">Jiannan, Cao</div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></div></div></div></div></div></div></div><br class=""></body></html>