help-gnustep
[Top][All Lists]
Advanced

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

Re: Can't use NSInvocation on NSFont


From: Richard Frith-Macdonald
Subject: Re: Can't use NSInvocation on NSFont
Date: Sat, 12 Apr 2003 06:20:01 +0100


On Friday, April 11, 2003, at 06:32  pm, Yen-Ju Chen wrote:

Hi,

 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.

You just think you did... the first argument of the setArgument:atIndex:
method is a pointer to the value to be set.
You got this right with '&valTraitM', but missed off the ampersand
before 'font'

That means that you set the thing pointed to by 'font' as the second
argument, and that happens to be the NSFont class.

Doing [inv setArgument: &font atIndex: 2] should fix the problem.

 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];





reply via email to

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