替换已弃用的 NSNibLoading 方法(loadNibFile:、loadNibNamed: 等)? [英] Replacements for the deprecated NSNibLoading methods (loadNibFile:, loadNibNamed:, etc.)?
问题描述
我发现了 NSBundle 中的 NSNibLoading 方法:
I have found that the NSNibLoading methods in NSBundle:
+[NSBundle loadNibFile:externalNameTable:withZone:]
+[NSBundle loadNibNamed:owner:]
-[NSBundle loadNibFile:externalNameTable:withZone:]
在 10.8 中都被标记为弃用 - 在 10.8 及更高版本中加载笔尖的正确方法是什么?
have all been marked deprecated in 10.8 - what is the proper way to load the nibs in 10.8 and later?
我正在尝试在我的应用程序中创建一个自定义工作表,我是否必须为自定义工作表创建带有 initWithWindowNibName
的 NSWindowController
?
I'm trying to create a custom sheet in my app, do I have to create NSWindowController
with initWithWindowNibName
for the custom sheet?
推荐答案
NSBundle
类方法 loadNibNamed:owner:
在 OS X v10.8 中已弃用,loadNibNamed:owner:topLevelObjects:
是 不是 和评论 在文档中说明原因:
The NSBundle
class method loadNibNamed:owner:
is deprecated in OS X v10.8,
loadNibNamed:owner:topLevelObjects:
is not and the comments in the documentation state why:
与遗留方法不同,对象遵循标准的可可内存管理规则;有必要通过使用 IBOutlets 或持有对数组的引用来保持对它们的强引用,以防止 nib 内容被释放.
这篇关于替换已弃用的 NSNibLoading 方法(loadNibFile:、loadNibNamed: 等)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!