<div dir="ltr">Hi,<div><br></div><div>The error is get is "<i><span style="font-family:Menlo;font-size:11px">Contextual type </span><span style="font-family:Menlo;font-size:11px;color:rgb(180,38,26)">'AnyObject'</span><span style="font-family:Menlo;font-size:11px"> cannot be used with dictionary literal</span></i>" - and I get the same issue with your approach. </div><div><br></div><div>With the CGFloat, I get "<i><span style="font-family:Menlo;font-size:11px">Value of type </span><span style="font-family:Menlo;font-size:11px;color:rgb(180,38,26)">'CGFloat'</span><span style="font-family:Menlo;font-size:11px"> does not conform to expected dictionary value type </span><span style="font-family:Menlo;font-size:11px;color:rgb(180,38,26)">'AnyObject'</span></i>'".<br></div><div><br></div><div>Simon</div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="text-align:center"></div><div style="text-align:center"><div style="color:rgb(0,0,0);text-align:start;word-wrap:break-word">Simon Gladman <a href="tel:%2B44%207973%20669691" value="+447973669691" style="color:rgb(17,85,204)" target="_blank">+44 7973 669691</a></div><div style="color:rgb(0,0,0);text-align:start;word-wrap:break-word"><br>Blog: <a href="http://flexmonkey.blogspot.co.uk/" style="color:rgb(17,85,204)" target="_blank">http://flexmonkey.blogspot.co.uk</a><br>GitHub: <a href="https://github.com/FlexMonkey" style="color:rgb(17,85,204)" target="_blank">https://github.com/FlexMonkey</a></div><div style="color:rgb(0,0,0);text-align:start;word-wrap:break-word">Twitter: <a href="https://twitter.com/FlexMonkey" style="color:rgb(17,85,204)" target="_blank">@FlexMonkey</a></div></div><br></div></div></div></div></div>
<br><div class="gmail_quote">On 24 May 2016 at 17:18, Charlie Monroe <span dir="ltr"><<a href="mailto:charlie@charliemonroe.net" target="_blank">charlie@charliemonroe.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">What error do you get (i.e. why doesn't it compile)?<div><br></div><div>Have you tried this?<div><br></div><div><div style="margin:0px;font-size:9px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">let</span><span> result: [</span><span style="color:#703daa">String</span><span> : </span><span style="color:#703daa">AnyObject</span><span>] = [</span></div><span class=""><div style="margin:0px;font-size:9px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)"><span style="color:#000000"><span style="white-space:pre-wrap">        </span></span><span>"inputImage"</span><span style="color:#000000">: [</span></div><div style="margin:0px;font-size:9px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)"><span style="color:#000000"><span style="white-space:pre-wrap">                </span></span><span>kCIAttributeIdentity</span><span style="color:#000000">: </span><span style="color:#272ad8">0</span><span style="color:#000000">,</span></div><div style="margin:0px;font-size:9px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)"><span style="color:#000000"><span style="white-space:pre-wrap">                </span></span><span>kCIAttributeClass</span><span style="color:#000000">: </span><span style="color:#d12f1b">"CIImage"</span><span style="color:#000000">,</span></div><div style="margin:0px;font-size:9px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)"><span style="color:#000000"><span style="white-space:pre-wrap">                </span></span><span>kCIAttributeDisplayName</span><span style="color:#000000">: </span><span style="color:#d12f1b">"Image"</span><span style="color:#000000">,</span></div><div style="margin:0px;font-size:9px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)"><span style="color:#000000"><span style="white-space:pre-wrap">                </span></span><span>kCIAttributeType</span><span style="color:#000000">: </span><span>kCIAttributeTypeScalar</span></div><div style="margin:0px;font-size:9px;line-height:normal;font-family:Menlo"><span><span style="white-space:pre-wrap">        </span>]</span></div><div style="margin:0px;font-size:9px;line-height:normal;font-family:Menlo"><span>]</span></div></span><div style="margin:0px;font-size:9px;line-height:normal;font-family:Menlo"><span>return result</span></div><div><br></div><div>Charlie</div><div>
</div>
<br><div><blockquote type="cite"><div><div class="h5"><div>On May 24, 2016, at 6:07 PM, simon gladman via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr"><div>Apologies for arriving a little late to the party and I hope this is a suitable forum to discuss this subject. I've spent some time over the last few days moving a large Core Image project to Swift 3.0 and come across some side effects which I think are related to proposal SE-0072, <i>Fully eliminate implicit bridging conversions from Swift</i>.</div><div><br></div><div>First off, rightly or wrongly, I've always typed the scalar parameters of my subclassed <i>CIFilters</i> as <i>CGFloat</i>. It makes working with <i>CIVectors</i> and <i>CGRects</i> cleaner and feels more "Swifty" than using <i>NSNumber</i>. However, moving to Swift 3.0, using anything apart from an <i>NSNumber</i> breaks. For example:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(4,51,255)">let</span><span> radius: </span><span style="color:rgb(52,149,175)">CGFloat</span><span> = 25</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span> </span><br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(4,51,255)">let</span><span> blur = </span><span style="color:rgb(52,149,175)">CIFilter</span><span>(</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> name: </span><span style="color:rgb(180,38,26)">"CIGaussianBlur"</span><span>,</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> withInputParameters: [</span><span style="color:rgb(52,149,175)">kCIInputRadiusKey</span><span>: radius])</span></div></div><div><br></div><div>The same with passing arguments to a <i>CIKernel</i>, <i>CIWarpKernel</i> or <i>CIColorKernel</i>:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> kernel.</span><span style="color:rgb(52,149,175)">apply</span><span>(</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> withExtent: </span><span style="color:rgb(52,149,175)">CGRect</span><span>(x: 0, y: 0, width: 100, height: 100)</span>,</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> arguments: [radius])</span></div></div><div><br></div><div>Secondly, the attributes property of a filter (of type <i>[String: AnyObject]</i>) which I'd normally code along the lines of:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(4,51,255)">override</span><span> </span><span style="color:rgb(4,51,255)">var</span><span> attributes: [</span><span style="color:rgb(52,149,175)">String</span><span> : </span><span style="color:rgb(52,149,175)">AnyObject</span><span>]</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(4,51,255)">return</span><span> [</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(180,38,26)">"inputImage"</span><span>: [</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(52,149,175)">kCIAttributeIdentity</span><span>: 0,</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(52,149,175)">kCIAttributeClass</span><span>: </span><span style="color:rgb(180,38,26)">"CIImage"</span><span>,</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175)"><span> </span><span>kCIAttributeDisplayName</span><span>: </span><span style="color:rgb(180,38,26)">"Image"</span><span>,</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175)"><span> </span><span>kCIAttributeType</span><span>: </span><span>kCIAttributeTypeScalar</span><span>]</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> ]</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> }</span></div></div><div><br></div><div>...fails to compile. <span style="font-family:Menlo;font-size:11px">kCIAttributeTypeScalar </span>is of type <i>String</i> and needs to be cast to <i>NSString</i> and the dictionary itself needs to be cast to <i>AnyObject</i>:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(4,51,255)">override </span><span style="color:rgb(4,51,255)">var</span> attributes: [<span style="color:rgb(52,149,175)">String</span> : <span style="color:rgb(52,149,175)">AnyObject</span>]</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(4,51,255)">return</span><span> [</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(180,38,26)">"inputImage"</span><span>: [</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(52,149,175)">kCIAttributeIdentity</span><span>: 0,</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(52,149,175)">kCIAttributeClass</span><span>: </span><span style="color:rgb(180,38,26)">"CIImage"</span><span>,</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175)"><span> </span><span>kCIAttributeDisplayName</span><span>: </span><span style="color:rgb(180,38,26)">"Image"</span><span>,</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175)"><span> </span><span>kCIAttributeType</span><span>: </span><span>kCIAttributeTypeScalar</span><span> </span><span style="color:rgb(4,51,255)">as</span><span> </span><span>NSString</span><span>] </span><span style="color:rgb(4,51,255)">as</span><span> </span><span>AnyObject</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> ]</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> }</span></div></div><div><br></div><div>It seems awkward to me that the constant supplied by Core Image to describe an attribute's type needs to be cast to another type to get it working. </div><div><br></div><div>Are these changes just something that we'll need to live with? Are they still in flux? Have I totally misunderstood everything and there's a more elegant solution?</div><div><br></div><div>Any thoughts would be greatly appreciated!</div><div><br></div><div>Simon</div><div><br></div><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div style="text-align:center"></div><div style="text-align:center"><div style="text-align:start;word-wrap:break-word">Simon Gladman <a href="tel:%2B44%207973%20669691" value="+447973669691" style="color:rgb(17,85,204)" target="_blank">+44 7973 669691</a></div><div style="text-align:start;word-wrap:break-word"><br>Blog: <a href="http://flexmonkey.blogspot.co.uk/" style="color:rgb(17,85,204)" target="_blank">http://flexmonkey.blogspot.co.uk</a><br>GitHub: <a href="https://github.com/FlexMonkey" style="color:rgb(17,85,204)" target="_blank">https://github.com/FlexMonkey</a></div><div style="text-align:start;word-wrap:break-word">Twitter: <a href="https://twitter.com/FlexMonkey" style="color:rgb(17,85,204)" target="_blank">@FlexMonkey</a></div></div><br></div></div></div></div></div>
</div></div></div>
_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></div></blockquote></div><br></div>