That's because class
is a keyword in Swift, therefore any valid method cannot be named class
. In the same way you cannot create a method named for
, while
or other keyword.
I wasn't able to reproduce the strike-out with my methods, however, naming a method var
(or other keyword) in obj-c makes it impossible to be called from Swift.
Edit
I was wrong. It's still possible to call class
from Swift using
var clazz: AnyClass? = self.`class`()
However, then the compiler says:
'Class' is unavailable: use 'dynamicType' instead
So the answer by Edwin Vermeers is the correct one.