NSApplication: Apple's documentation in Objective C, why?

In the Overview of Apple's documentation for NSApplication, there are code examples in Objective C although I chose Swift in the upper right corner.

https://developer.apple.com/documentation/appkit/nsapplication


I can't quite make sense of this. Am I missing some important aspect or is it a pure mistake in the documentation?

Replies

In Swift, you have the @NSApplicationMain before the AppDelegate declaration. Such as:


@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {


But you do not have to write the code described in the doc.

Thanks, yes I know that this is the common way to do it but I was thinking this text is about alternative methods and if you switch from Objective C to Swift the text above the code example is changed accordingly but the code example is not. The text is referencing terms not in the code example, like this:

"create the

NSApplication
instance by calling the
shared
class method."


But there's no method called shared in the example code. So what do they actually mean in this section?

You are right. There are some places where Swift doc just points to older objc document.


On this chapter it is pretty annoying because it creates confusion on a root subject.


The good news is that the app templactes provide you with the correct framework.


However, you could file a documentation bug.