Sure. I'm not sure we have a good idea for how to catch the bug—what if you 
really meant to pass the array as an NSArray?—but it's worth recording 
somewhere. Thanks, Rick.

Jordan


> On Nov 14, 2017, at 18:00, Rick Mann <rm...@latencyzero.com> wrote:
> 
> I tried to find an alternative init() to use, but couldn't (despite dozens of 
> releases, Xcode's code completion still fails much of the time). Thanks for 
> pointing me to the right one!
> 
> Should I file a bug?
> 
>> On Nov 14, 2017, at 17:47 , Jordan Rose <jordan_r...@apple.com> wrote:
>> 
>> Heh, it would be nice to catch this. You're collecting a bunch of arguments 
>> in an Array, and then passing that array straight on as a single argument 
>> itself, which means it gets passed as either an NSArray or a pointer (not 
>> sure which). Use 'init(format:arguments:)' instead.
>> 
>> Jordan
>> 
>> 
>>> On Nov 14, 2017, at 17:19, Rick Mann via swift-users 
>>> <swift-users@swift.org> wrote:
>>> 
>>> I've had a long-working `debugLog()` method that looks like this:
>>> 
>>> ```
>>> func
>>> debugLog<T>(_ inMsg: T, file inFile : String = #file, line inLine : Int = 
>>> #line)
>>> {
>>>     let file = (inFile as NSString).lastPathComponent
>>>     let s = "\(file):\(inLine)    \(inMsg)"
>>>     print(s)
>>> }
>>> ```
>>> 
>>> I wanted to add a version that works like `String(format:)`:
>>> 
>>> ```
>>> func
>>> debugLog(format inFormat: String, file inFile : String = #file, line inLine 
>>> : Int = #line, _ inArgs: CVarArg...)
>>> {
>>>     let s = String(format: inFormat, inArgs)
>>>     debugLog(s, file: inFile, line: inLine)
>>> }
>>> 
>>> ```
>>> 
>>> While this compiles and executes, all of the values are zero for this 
>>> example:
>>> 
>>> ```
>>> let xc = CGFloat(1.0)
>>> let yc = CGFloat(0.0)
>>> let len = CGFloat(282.1364917907643)
>>> 
>>> debugLog(format: "Pixel %f, %f length too far %f", xc, yc, len)
>>> ```
>>> 
>>> Output:
>>> 
>>> ```
>>> FisheyeImageRenderer.swift:108    Pixel 0.000000, 0.000000 length too far 
>>> 0.000000
>>> ```
>>> 
>>> Something is being misinterpreted in the passing of `inArgs: CVarArg...`
>>> 
>>> TIA,
>>> 
>>> -- 
>>> Rick Mann
>>> rm...@latencyzero.com
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> swift-users mailing list
>>> swift-users@swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-users
>> 
> 
> 
> -- 
> Rick Mann
> rm...@latencyzero.com
> 
> 

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to