<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">As alternative to a protocol solution, you can use value type wrapper:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" class="">struct</span> Delegate<T <span style="font-variant-ligatures: no-common-ligatures; color: #35568a" class="">where</span> T:UIViewController, T:UITableViewDelegate> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #35568a" class="">let</span> value: <span style="font-variant-ligatures: no-common-ligatures; color: #c35900" class="">T</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(195, 89, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" class="">class</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> MyController : </span>UIViewController<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, </span>UITableViewDelegate<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" class="">class</span> WrongController : <span style="font-variant-ligatures: no-common-ligatures; color: #c35900" class="">UIViewController</span> {}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" class="">let</span> delegate = <span style="font-variant-ligatures: no-common-ligatures; color: #c35900" class="">Delegate</span>(value: <span style="font-variant-ligatures: no-common-ligatures; color: #c35900" class="">MyController</span>())</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);" class="">// error: generic parameter 'T' could not be inferred</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #35568a" class="">let</span> delegate = <span style="font-variant-ligatures: no-common-ligatures; color: #c35900" class="">Delegate</span>(value: <span style="font-variant-ligatures: no-common-ligatures; color: #c35900" class="">WrongController</span>())</div></div><div class=""><br class=""></div><div class="">- Alexey Demedetskiy</div><div class=""><br class=""></div>
> Hi All,<br class="">> I used to do this in Obj-C but I'm unable to do this in swift<br class="">> <br class="">> *UIViewController<MyProtocol>*delegate;*<br class="">> <br class="">> I posted this question on dev forums but didn't get the solution and<br class="">> finally I'm reporting here so that It can be added as a features in the<br class="">> coming releases.<br class="">> <br class="">> Thanks<br class="">> <br class="">> Rathore<br class="">> <br class="">> <br class="">><span class="Apple-converted-space"> </span>
</body></html>