0

I'm writing a Commandline app on Xcode with C++ and am trying to replace the deprecated methods KillProcess(), GetNextProcess(), and CopyProcessName(). Documentation recommends using NSApplication-related methods but importing Foundation.h and AppKit.h results in many compiler errors.

How would one replace these deprecated methods without using NSApplication-related methods?

Thanks.

Undefined Behaviour
  • 729
  • 2
  • 8
  • 27
Lenny
  • 388
  • 3
  • 15

1 Answers1

1

NSApplication is a Cocoa object, targeted for Objective-C or Swift development, not C++ development (though you could use Objective-C++).

You need to add a source file with the extension .swift or .m (or .mm for Objective-C++) to your project and #import the Cocoa headers, then write code in the appropriate language.

The rest of the application, other than the code that calls into the Cocoa APIs, can still be written in C++ if you want.

(Note that it's generally inaccurate to say that you have a "C++ application." It is possible to have an application where the entirety of the code is in C++, but often an app will have a mixture of C, C++, and possibly other languages mixed together.)

Dan Korn
  • 1,274
  • 9
  • 14