Skip navigation.
 
mlNSLog(@"%@",[NSProxy class]);
FROM : Agent M
DATE : Sat Mar 11 21:08:19 2006

I have come across a difficulty with an NSProxy subclass on 10.3.9
which can be summed up with the following lines:

Class p=[NSProxy class];
NSLog(@"class %@",p);

The second line throws an exception:
*** Uncaught exception: <NSInvalidArgumentException> *** -[NSProxy
methodSignatureForSelector:] called!

If "NSProxy" above is any NSObject subclass, then it prints the class
name as expected.

The reason this occurs is because +[NSProxy class] does not implement
the proper description method. Apparently, not all meta-classes are
created equal.

-----
Workarounds are:
1) NSLog(@"class %@",NSStringFromClass([NSProxy class]));
or
2)
@implementation NSProxy (Desc)
+(NSString*)_copyDescription //yes, this is a private method
{
   return [NSStringFromClass([self class]) copy]; //extra retain
increment is critical here
}
@end

I found solution (2) by adding a category on NSProxy:
-(NSMethodSignature*)methodSignatureForSelector:(SEL)sel
{
   NSLog(@"selector! %@",NSStringFromSelector(sel));
   return nil;
}

Because NSProxy is a stripped down root object, perhaps this is how
things are supposed to behave; but I hope this will help anyone who
comes across this in the future.

¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬
AgentM
<email_removed>
¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬

Related mailsAuthorDate
mlNSLog(@"%@",[NSProxy class]); Agent M Mar 11, 21:08
mlRe: NSLog(@"%@",[NSProxy class]); Philippe Mougin Mar 12, 01:03
mlRe: NSLog(@"%@",[NSProxy class]); Greg Herlihy Mar 12, 01:30
mlRe: NSLog(@"%@",[NSProxy class]); Agent M Mar 12, 01:54
mlRe: NSLog(@"%@",[NSProxy class]); Philippe Mougin Mar 12, 02:20
mlRe: NSLog(@"%@",[NSProxy class]); glenn andreas Mar 12, 03:24
mlRe: NSLog(@"%@",[NSProxy class]); Agent M Mar 12, 04:59
mlRe: NSLog(@"%@",[NSProxy class]); glenn andreas Mar 12, 05:55
mlRe: NSLog(@"%@",[NSProxy class]); Philippe Mougin Mar 12, 14:10
mlRe: NSLog(@"%@",[NSProxy class]); Agent M Mar 18, 03:56