English 中文(简体)
为什么要叫作NSApplication。 分享直接忽视了Info.plist中特等班子规定的类别?
原标题:Why does calling NSApplication.shared directly ignore the class specified by the Principal class in Info.plist?

我谨使用https://developer.apple.com/documentation/appkit/nsapplication” rel=“nofollow noreferer”>NSApplication,以创建我的方案申请表。 由NSApplication.commdNSApp <><>>><>/code><<<<<>>><>>>>>>>>><>>>>>>>>><>>>>>>>>>><>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 应为<代码>应用类别:

class Application: NSApplication {
    // My own methods
}

我首先试图在<代码>Info.plist 上设定特等类别,从NSApplication,但我后来获悉,我不得不使用$(PRODUCT_MODULE_NAME)。 我在尝试时,用一种新的macOS应用模板,除修改特等类别<>外,不作任何改动,并添加该代码,界定我的子类别。


问题是,上述改动对具有不同结构的现有申请项目没有任何影响。

为了在新项目中照搬,我删除了<代码>.xib/。 AppDelegate.swift file with only a main.swift 载有下列内容的档案:

import Cocoa
class Application: NSApplication, NSApplicationDelegate {
    func applicationShouldTerminateAfterLastWindowClosed(_ _: NSApplication) -> Bool {
        return true
    }
}
NSApplication.shared.delegate = (NSApp as! Application)
NSApp.run()

在此情况下,<代码>as! 页: 1 删除<条码>Info.plist似乎完全没有效果。

我怀疑另一个项目结构,包括一名代表,附有<代码>@NSApplicationMain,有些代表则在上登记了特等类别的价值,用于即审申请,但使用NSApplication. Commond,以人工方式启动申请并不包括这一步骤。

在我使用<代码>NSApplication的情况下,我如何使用一个习惯类别来申请。 直接共享。

In case this matters my macOS version is 10.15.7 and my Swift version is 5.3.2.

问题回答




相关问题
2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is ...

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

Switching J2SE versions on Mac OS (SnowLeopard)

My current JDK on Mac OS (10.6) is set to 1.6 and I d like to switch to 1.5. A listing of /System/Library/Frameworks/JavaVM.framework/Versions/ shows: lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 ...

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签