• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSLog(@"%@",[NSProxy class]);
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Subject: NSLog(@"%@",[NSProxy class]);
  • From: Agent M <email@hidden>
  • Date: Sat, 11 Mar 2006 15:08:19 -0500

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@hidden
¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSLog(@"%@",[NSProxy class]);
      • From: Agent M <email@hidden>
  • Prev by Date: Getting local timezone as integer
  • Next by Date: Re: Getting local timezone as integer
  • Previous by thread: Re: Getting local timezone as integer
  • Next by thread: Re: NSLog(@"%@",[NSProxy class]);
  • Index(es):
    • Date
    • Thread