[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can't use NSInvocation on NSFont

From: Yen-Ju Chen
Subject: Can't use NSInvocation on NSFont
Date: Fri, 11 Apr 2003 13:32:22 -0400


 I tried to use NSInvocation but failed.

 Below is the testing code.
 It always complains that
 "NSInvalidArgumentException: NSFont(class) does not recognize fontInfo".
 I surely put the instance as argument, not class.

 Thanx a lot.


#include <AppKit/AppKit.h>

int main(int argc, const char *argv[])
 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 NSFont *font;
 NSFontManager *manager;
 NSInvocation *inv;
 NSFontTraitMask valTraitM;

 [NSApplication sharedApplication];

 manager = [NSFontManager sharedFontManager];
 font = [NSFont systemFontOfSize: [NSFont systemFontSize]];
 NSLog(@"font %@", font);

 valTraitM = NSBoldFontMask;
inv = [NSInvocation invocationWithMethodSignature: [manager methodSignatureFor
Selector: @selector(convertFont:toHaveTrait:)]];
 [inv setSelector: @selector(convertFont:toHaveTrait:)];
 [inv setTarget: manager];
 [inv setArgument: font atIndex: 2];
 [inv setArgument: &valTraitM atIndex: 3];
 [inv invoke];
 [inv getReturnValue: &font];

 NSLog(@"font %@", font);


 return 0 ;

Add photos to your messages with MSN 8. Get 2 months FREE*.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]