In the vein of...
@implementation MyClass
- (id) objectForKeyedSubscript:(id)k {
return [self something:k];
}
Is it also possible to "subscript" Class objects? I too, am about to find out, with you.. but thought I would post this question as I tested it out, myself...
+ (id) objectForKeyedSubscript:(id)k {
return [self.shared something:k];
}
And alas.. it is not...
id x = MyClass[@"document"];
error: unexpected interface name 'MyClass': expected expression
But why, Daddy? Class' sure get the short end of NSObject's stick, if you ask me.
MyClass.shared[@"document"];id myClass = [MyClass class]; myClass[@"document"];Or[MyClass class][@"document"].id MyClassReaper(NSString *str) { return objc_msgSend(MyClass.class, NSSelectorFromString(str)); }, etc... Again, these examples are only illustrative.