<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="">Hi Simon,<div class=""><br class=""></div><div class="">This behavior is intentional; implicit bridging conversions are slated for removal in Swift 3.</div><div class=""><br class=""></div><div class="">More information: <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0072-eliminate-implicit-bridging-conversions.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0072-eliminate-implicit-bridging-conversions.md</a></div><div class=""><br class=""></div><div class="">Best,</div><div class="">Austin</div><div class=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">On May 23, 2016, at 12:44 AM, simon gladman via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi All,</div><div class=""><br class=""></div><div class="">I thought I'd attempt updating the code of my <a href="https://github.com/FlexMonkey/Filterpedia" class="">Filterpedia</a> app to Swift 3. The transition has been pretty smooth so far, but I have a few issues. I guess my question over these issues is, are they features or bugs in an early Swift 3 release?</div><div class=""><br class=""></div><div class="">First off, overriding CIFilter requires overriding the <i class="">attributes</i> var which is of type <i class="">[String: AnyObject</i>]. In Swift 2, the following works perfectly:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">override</span><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">var</span><span style="" class=""> attributes: [</span><span style="color:rgb(52,149,175)" class="">String</span><span style="" class=""> : </span><span style="color:rgb(52,149,175)" class="">AnyObject</span><span style="" class="">] {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">return</span><span style="" class=""> [</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 149, 175);" class=""><span style="" class=""> </span><span style="" class="">kCIAttributeFilterDisplayName</span><span style="" class="">: </span><span style="color:rgb(180,38,26)" class="">"CMYK Levels"</span><span style="" class="">,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(180,38,26)" class="">"inputImage"</span><span style="" class="">: [</span><span style="color:rgb(52,149,175)" class="">kCIAttributeIdentity</span><span style="" class="">: 0,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(52,149,175)" class="">kCIAttributeClass</span><span style="" class="">: </span><span style="color:rgb(180,38,26)" class="">"CIImage"</span><span style="" class="">,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(52,149,175)" class="">kCIAttributeDisplayName</span><span style="" class="">: </span><span style="color:rgb(180,38,26)" class="">"Image"</span><span style="" class="">,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(52,149,175)" class="">kCIAttributeType</span><span style="" class="">: </span><span style="color:rgb(52,149,175)" class="">kCIAttributeTypeImage</span><span style="" class="">]</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> ]</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> }</span></div></div><div class=""><br class=""></div><div class="">However, because the inputImage dictionary entry is a dictionary itself and kCIAttributeTypeImage is a string, in Swift 3, it appears I have to explicitly case them to compile:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">override</span><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">var</span><span style="" class=""> attributes: [</span><span style="color:rgb(52,149,175)" class="">String</span><span style="" class=""> : </span><span style="color:rgb(52,149,175)" class="">AnyObject</span><span style="" class="">] {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">return</span><span style="" class=""> [</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 149, 175);" class=""><span style="" class=""> </span><span style="" class="">kCIAttributeFilterDisplayName</span><span style="" class="">: </span><span style="color:rgb(180,38,26)" class="">"CMYK Levels"</span><span style="" class="">,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(180,38,26)" class="">"inputImage"</span><span style="" class="">: [</span><span style="color:rgb(52,149,175)" class="">kCIAttributeIdentity</span><span style="" class="">: 0,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(52,149,175)" class="">kCIAttributeClass</span><span style="" class="">: </span><span style="color:rgb(180,38,26)" class="">"CIImage"</span><span style="" class="">,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(52,149,175)" class="">kCIAttributeDisplayName</span><span style="" class="">: </span><span style="color:rgb(180,38,26)" class="">"Image"</span><span style="" class="">,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 149, 175);" class=""><span style="" class=""> </span><span style="" class="">kCIAttributeType</span><span style="" class="">: </span><span style="" class="">kCIAttributeTypeImage</span><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">as</span><span style="" class=""> </span><span style="" class="">AnyObject</span><span style="" class="">] </span><span style="color:rgb(4,51,255)" class="">as</span><span style="" class=""> </span><span style="" class="">AnyObject</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> ]</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> }</span></div></div><div class=""><br class=""></div><div class="">There's a similar casting issue with the <i class="">arguments</i> parameter of a kernel's <i class="">apply</i> method. In Swift 2, the following compiles without issue:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">let</span><span style="" class=""> kernel = </span><span style="color:rgb(52,149,175)" class="">CIColorKernel</span><span style="" class="">()</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><span style="" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">let</span><span style="" class=""> rect = </span><span style="color:rgb(52,149,175)" class="">CGRect</span><span style="" class="">(</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> x: 0, y: 0,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> width: 100, height: 100)</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><span style="" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">let</span><span style="" class=""> inputRadius: </span><span style="color:rgb(52,149,175)" class="">CGFloat</span><span style="" class=""> = 5.678</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">let</span><span style="" class=""> inputCenter = </span><span style="color:rgb(52,149,175)" class="">CIVector</span><span style="" class="">(x: 12.3, y: 45.6)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">let</span><span style="" class=""> inputRect = </span><span style="color:rgb(52,149,175)" class="">CIVector</span><span style="" class="">(cgRect: rect)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">let</span><span style="" class=""> inputString = </span><span style="color:rgb(180,38,26)" class="">"Xyzzy"</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><span style="" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">let</span><span style="" class=""> arguments = [inputRect,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> inputRadius,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> inputCenter,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> inputString]</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><span style="" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> kernel.</span><span style="color:rgb(52,149,175)" class="">apply</span><span style="" class="">(</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> withExtent: rect,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> arguments: arguments)</span></div></div><div class=""><br class=""></div><div class="">While in 3, I need to do the following:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> </span><span style="color:rgb(4,51,255)" class="">let</span><span style="" class=""> arguments = [inputRect,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> inputRadius </span><span style="color:rgb(4,51,255)" class="">as</span><span style="" class=""> </span><span style="color:rgb(52,149,175)" class="">AnyObject</span><span style="" class="">,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> inputCenter,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="" class=""> inputString </span><span style="color:rgb(4,51,255)" class="">as</span><span style="" class=""> </span><span style="color:rgb(52,149,175)" class="">AnyObject</span><span style="" class="">] </span><span style="color:rgb(4,51,255)" class="">as</span><span style="" class=""> [</span><span style="color:rgb(52,149,175)" class="">AnyObject</span><span style="" class="">]</span></div></div><div class=""><br class=""></div><div class="">Any thoughts anybody?</div><div class=""><br class=""></div><div class="">Cheers!</div><div class=""><br class=""></div><div class="">Simon</div><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div style="text-align:center" class=""></div><div style="text-align:center" class=""><div style="text-align: start; word-wrap: break-word;" class="">Simon Gladman <a href="tel:%2B44%207973%20669691" value="+447973669691" style="color:rgb(17,85,204)" target="_blank" class="">+44 7973 669691</a></div><div style="text-align: start; word-wrap: break-word;" class=""><br class="">Blog: <a href="http://flexmonkey.blogspot.co.uk/" style="color:rgb(17,85,204)" target="_blank" class="">http://flexmonkey.blogspot.co.uk</a><br class="">GitHub: <a href="https://github.com/FlexMonkey" style="color:rgb(17,85,204)" target="_blank" class="">https://github.com/FlexMonkey</a></div><div style="text-align: start; word-wrap: break-word;" class="">Twitter: <a href="https://twitter.com/FlexMonkey" style="color:rgb(17,85,204)" target="_blank" class="">@FlexMonkey</a></div></div><br class=""></div></div></div></div></div>
</div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></div></body></html>