Swiftlint: How to ignore some instances of the force cast rule

Created on 1 Oct 2015  ·  3Comments  ·  Source: realm/SwiftLint

I have some cases where I want to use a force cast - e.g. when it would be a programming error if the force failed. One example is loading a view controller from a storyboard. Is there any way to ignore specific violations of a rule?

Thanks,
_David_

Most helpful comment

You can wrap your valid cases in comments:

// swiftlint:disable force_cast
let foo = bar as! Bad
// swiftlint:enable force_cast

All 3 comments

You can wrap your valid cases in comments:

// swiftlint:disable force_cast
let foo = bar as! Bad
// swiftlint:enable force_cast

Great, that works. Thanks!

No problem, we'll update the readme soon!

Was this page helpful?
0 / 5 - 0 ratings