Here is my code:
if let runningTests = NSClassFromString("XCTestCase") {
return false
}
The compiler warning:
"Constant 'runningTests' inferred to have type 'AnyClass', which may be unexpected.
What is it I need to cast to to remove this warning without changing my code into a if != nil check on the result of NSClassFromString?
You actually mean AnyClass
here, so you just need to tell the compiler that:
if let runningTests: AnyClass = NSClassFromString("XCTestCase") {
return false
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With