[Biococoa-dev] Base test

Jim Balhoff james.balhoff at duke.edu
Fri Aug 13 15:22:16 EDT 2004


On Aug 13, 2004, at 3:15 PM, Alexander Griekspoor wrote:

>> A classes are objects, it seems like it would work.
>
> I'm not so sure about that, but probably you are right. Anyway, the  
> description says:
>
> objc_msgSend
>
> Sends a message with a simple return value to an instance of a class.
>
> So I'm afraid it doesn't work on the class itself. I couldn't get it  
> to work either, but perhaps I'm doing something else wrong here...
>
>

It works, try this:

******************************************main.m************************ 
********
#import <Foundation/Foundation.h>
#import "MyClass.h"

int main (int argc, const char * argv[]) {
     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     SEL message = NSSelectorFromString(@"giveMeAnA");
     NSString *result = objc_msgSend([MyClass class], message);
     NSLog(result);
     [pool release];
     return 0;
}
******************************************main.m************************ 
********

******************************************MyClass.h********************* 
***********
#import <Foundation/Foundation.h>


@interface MyClass : NSObject {

}

+ (NSString *)giveMeAnA;

@end
******************************************MyClass.h********************* 
***********

******************************************MyClass.m********************* 
***********
#import "MyClass.h"


@implementation MyClass

+ (NSString *)giveMeAnA
{
     return @"A";
}

@end
******************************************MyClass.m********************* 
***********
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2373 bytes
Desc: not available
URL: <http://www.bioinformatics.org/pipermail/biococoa-dev/attachments/20040813/60d0bce0/attachment.bin>


More information about the Biococoa-dev mailing list