Swift : Why is the class method struck out

objective-c-runtime, swift

Solution

As you can see in the documentation, it's only available in Objective C and not in swift. See: https://developer.apple.com/documentation/objectivec/nsobject/1571950-class

I think this is because the AnyObject gives you enough information (More than the NSObject) for instance you can do `NSStringFromClass(BaseObject)` in swift instead of the `NSStringFromClass([BaseObject class])` that you do in Objective C

Problem

As long as a Swift class extends from NSObject we can pass it to the Objective-C runtime and ask it to introspect it for us. We have three options: - class - classForCoder - classForKeyedArchiver . . however class is struck out. (See image). Why is this?

Original source