Possible Duplicate:
How do I declare class-level properties in Objective-C?
Objective-C 2.0 dot notation - Class methods?
Objective-C's @property declarations do not allow you to specify class-level properties. For instance, you can't do this...
@interface NSObject (MyExtension)
+ @property (nonatomic, copy) NSString * className;
@end
...but I remember reading that properties are really just syntactical sugar for get/set messages, so when you type something.foo, you're really just sending either a [something foo] or a [something setFoo:newFooVal] message.
So I had an idea, and wrote this normal class-level member...
@interface NSObject (MyExtension)
+ (NSString *) className;
@end
and in the 'm' file, added this (again, completely normal)...
#import "IS_NSObject.h"
@implementation NSObject (MyExtension)
+ (NSString *) className
{
return NSStringFromClass([self class]);
}
@end
...and sure enough, to get a string representation of any class name, I can now just do this...
NSString * holderForClassName = UICollectionView.className;
Voila! A class-level property! Not even a compiler warning!
Actually, the only thing missing is the suggestion in the code-completion/intellisense. But it does of course if you type it like this...
NSString * holderForClassName = [UICollectionView className];
So of course, the question is... did I basically just 'discover' (i.e. it's always been right there but its not used like this) a class-level property?
(Well, ok, property syntax, but that's what I was after for chaining purposes rather than nesting tons of brackets.)