Re: How to get a Category method?
Re: How to get a Category method?
- Subject: Re: How to get a Category method?
- From: Ondra Cada <email@hidden>
- Date: Mon, 15 Mar 2004 01:38:00 +0100
A propos...
On Monday, Mar 15, 2004, at 01:23 Europe/Prague, Ondra Cada wrote:
No problem. Did you?
... here you go including the implementations, both for class and
instance, for an easily #defineable class:
41 /tmp> <q.m
#import <Foundation/Foundation.h>
#define CLASS NSString // class to be tested
int main() {
[NSAutoreleasePool new];
SEL sel=NSSelectorFromString(@"justATest");
#define _NAME(x) #x
#define NAME(x) _NAME(x)
NSLog(@"class %s responds: %d",NAME(CLASS),[CLASS
respondsToSelector:sel]);
NSLog(@"instance responds: %d",[[CLASS new] respondsToSelector:sel]);
NSLog(@"class implementation: 0x%x",[CLASS methodForSelector:sel]);
NSLog(@"instance implementation (from class): 0x%x",[CLASS
instanceMethodForSelector:sel]);
NSLog(@"instance implementation (from instance): 0x%x",[[CLASS new]
methodForSelector:sel]);
return 0;
}
@implementation CLASS (JustATest)
+(void)justATest {}
-(void)justATest {}
@end
42 /tmp> cc -Wall -framework Foundation q.m && ./a.out
2004-03-15 01:37:04.004 a.out[23889] class NSString responds: 1
2004-03-15 01:37:04.006 a.out[23889] instance responds: 1
2004-03-15 01:37:04.007 a.out[23889] class implementation: 0x2bf8
2004-03-15 01:37:04.008 a.out[23889] instance implementation (from
class): 0x2c18
2004-03-15 01:37:04.009 a.out[23889] instance implementation (from
instance): 0x2c18
43 /tmp>
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.