gpt4 book ai didi

objective-c - NSApp 是否终止 :id deprecated?

转载 作者:太空狗 更新时间:2023-10-30 03:27:54 25 4
gpt4 key购买 nike

我一直在寻找如何以编程方式终止我的应用程序。我在许多主题中发现人们使用 NSApp terminate:id

在 Xcode 中 terminate:id 被划掉了。这种方法被弃用了吗?我应该用它来终止我的申请吗?如果不是,哪种方法是正确的?

更新:当我说它交叉时我的意思的图片: enter image description here

最佳答案

我没有看到 terminate 被弃用。编译器警告的一个可能原因可能是在

[NSApp terminate:sender]

NSApp 返回一个通用的 id,因此编译器不知道哪个 terminate 消息实际上意味着什么。事实上,如果我使用“跳转到定义”,Xcode 会跳转到

@protocol NSInputServiceProvider
...
- (void) terminate:(id)sender NS_DEPRECATED_MAC(10_0, 10_6);

但是如果你使用等效的代码

[[NSApplication sharedApplication] terminate:sender];

然后编译器警告消失。

关于objective-c - NSApp 是否终止 :id deprecated?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15853230/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com