Swiftlint: compiler_protocol_init false positive when calling NSNumber(integerLiteral)

Created on 11 Jan 2017  路  2Comments  路  Source: realm/SwiftLint

After bumping to SwiftLint 0.16.0, I'm getting a compiler_protocol_init when using NSNumber(integerLiteral:) (or any NSNumber literal initialiser).
I have to use NSNumber due to some Objective-C code (a method called from swift code which is taking an array of NSNumber).

Since there's no literal to create a NSNumber in swift (is there one?), I think that's a false positive 馃槵

Most helpful comment

You can use a number literal to create an NSNumber instance as follows:

let number: NSNumber = 10
// or
let number = 10 as NSNumber

All 2 comments

You can use a number literal to create an NSNumber instance as follows:

let number: NSNumber = 10
// or
let number = 10 as NSNumber

Didn't though about this. Thanks!

Was this page helpful?
0 / 5 - 0 ratings