user808667
user808667

Reputation: 343

Subclassing NSFontManager doesn't work

I subclassed NSFontManager and overrode "modifyFont:(id)sender) Then I changed the NSFontManager class in my xib files to the new class. I can see, that the class is initialized, but the overwritten method is never called. Though the NSFontManager method works normal.

What do I wrong?

#import "GFFontManager.h"

@implementation GFFontManager

-(id)init{
    if (self = [super init]) {
        //this is called
        NSLog(@"GFFontManager init");
    }
    return self;
}

-(void)modifyFont:(id)sender{
    //this is never called
    NSLog(@"Do something");
    [super modifyFont:sender];
}

@end

Upvotes: 2

Views: 298

Answers (1)

user808667
user808667

Reputation: 343

OK - here is how it works:

I added the following to the main.c and it worked like a charm!

#import <Cocoa/Cocoa.h>
#import "GFFontManager.h"

int main(int argc, char *argv[])
{
    [NSFontManager setFontManagerFactory: [GFFontManager class]];
    return NSApplicationMain(argc,  (const char **) argv);
}

Best regards - Gerald

Upvotes: 2

Related Questions