Objective C - Calling a static method on a Class type object?
I get the following error: Class is not an object开发者_如何学JAVAive c class name
- (void)CallStaticMethodForClass :(Class *)myClass
{
[myClass doSomething];
}
+ (void)doSomething
{
//
}
It should be declared as:
- (void)callMethodOnClass:(Class)myClass { ...
A couple things:
- The pointer (
*
) is unnecessary when referring to aClass
. Command-double click "Class
" to see why (it's part of thetypedef
) - We don't start our methods with a capital letter
- There's no such thing as a "static" method in Objective-C. We have "class methods".
精彩评论