1

ALL,

The following code:

in fontpropertypage.cpp:

#import "AppKit/AppKit.h"

CFontPropertyPage::CFontPropertyPage()
{
    m_font = font;
    NSFontManager *manager = [NSFontManager sharedFontManager];
    NSFontPanel *panel = [manager fontpanel:true];
}

In the fontpropertypage.mm

#include "fontpropertypage.cpp"

I'm receiving the error in subject from the Xcode when trying to get NSFontPanel pointer.

Can someone please help with the fix?

Both files are present in the Xcode project.

TIA!!

Igor
  • 5,620
  • 11
  • 51
  • 103

1 Answers1

1

NSFontManager and NSFontPanel are GUI objects in Cocoa and can only be accessed with Objective-C (or Objective C++, your .mm file).

This code would surely compile if you put it directly in the .mm file, but having it in a .cpp file that you're including is wierd (I usually only ever include header files like .h or .hpp).

I suggest putting that class directly into the .mm file.

Also, the code you have up there has a few errors in general:

CFontPropertyPage::CFontPropertyPage()
{
    // m_font should be a class member ; what about font? 
    m_font = font;
    NSFontManager *manager = [NSFontManager sharedFontManager];
    // fontPanel needs a capital P
    NSFontPanel *panel = [manager fontPanel:true];
}
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215