aryaxt
aryaxt

Reputation: 77596

Objective C - Calling a static method on a Class type object?

I get the following error: Class is not an objective c class name

- (void)CallStaticMethodForClass :(Class *)myClass
{
     [myClass doSomething];
}

+ (void)doSomething
{
     //
}

Upvotes: 1

Views: 2483

Answers (1)

Dave DeLong
Dave DeLong

Reputation: 243146

It should be declared as:

- (void)callMethodOnClass:(Class)myClass { ...

A couple things:

  1. The pointer (*) is unnecessary when referring to a Class. Command-double click "Class" to see why (it's part of the typedef)
  2. We don't start our methods with a capital letter
  3. There's no such thing as a "static" method in Objective-C. We have "class methods".

Upvotes: 7

Related Questions