+ (Class) classOf1 { return self ; }
self in a class method is a Class object of the current class, so here self is a class object for class Foo
+ (Class) classOf2 { return [Foo class] ; }
and here is the class object for class Foo
+ (Class) classOf3 { return [[[Foo class] new] class] ; }
this is the same as
Class fooClass = [Foo class]; id fooInstance = [fooClass new]; return [fooInstance class];
which will again provide you with an object of class class Foo
+ (Class) classOf4 { return [[self new] class] ; }
just like the previous one, just replace [Foo class] with self
+ (Class) classOf5 { return [[[self alloc] init] class] ; }
just like the previous one, just replace [Foo new] with [[Foo alloc] init]
+ (Class) classOf6 { return [[[Foo alloc] init] class] ; }
just like the previous one, just replace self with Foo
+ (Class) classOf7 { return [self class] ; }
like the second, just replace Foo with self
The difference between using Foo and self in a class method is that when this method is called in a subclass, self will be replaced with a subclass. eg.
@interface Bar : Foo @end Class barClass = [Bar classOf1];
If you really want to get a class of a class (e.g. metaclass), you need to use the objc execution function from <objc/runtime.h>
id metaClass = objc_getMetaClass("Foo");