It is assumed to be of the type "AnyClass", which may be unexpected.

Here is my code:

if let runningTests = NSClassFromString("XCTestCase") {
    return false
}

Compiler Warning:

Persistent runTests are assumed to be of the AnyClass type, which may be unexpected.

What do I need to do to remove this warning without changing my code to check if! = Nil with the result of NSClassFromString?

+4
source share
1 answer

Actually, you mean AnyClasshere, so you just need to tell the compiler that:

if let runningTests: AnyClass = NSClassFromString("XCTestCase") {
    return false
}
+6
source

All Articles