折旧的NSNibLoading方法(loadNibFile :, loadNibNamed :,等)的替换? [英] Replacements for the depreciated NSNibLoading methods (loadNibFile:, loadNibNamed:, etc.)?

查看:329
本文介绍了折旧的NSNibLoading方法(loadNibFile :, loadNibNamed :,等)的替换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现NSBundle中的NSNibLoading方法:

  + [NSBundle loadNibFile:externalNameTable:withZone:] 
+ [NSBundle loadNibNamed:owner:]
- [NSBundle loadNibFile:externalNameTable:withZone:]

都已在10.8中被标记为弃用 - 在10.8和更高版本中加载nib的正确方法是什么?



我试图在我的应用程序,我必须创建 NSWindowController initWithWindowNibName 为自定义工作表吗?


< NSBundle 类方法 loadNibNamed:owner:在OS X v10.8中已弃用,

loadNibNamed:owner:topLevelObjects:和注释在文档中状态为什么:


与传统方法不同,对象遵循标准的可可内存管理规则;必须通过使用IBOutlet或保存对数组的引用来保持对它们的强引用,以防止nib内容被重新分配。



I have found that the NSNibLoading methods in NSBundle:

+[NSBundle loadNibFile:externalNameTable:withZone:]
+[NSBundle loadNibNamed:owner:]
-[NSBundle loadNibFile:externalNameTable:withZone:]

have all been marked deprecated in 10.8 - what is the proper way to load the nibs in 10.8 and later?

I'm trying to create a custom sheet in my app, do I have to create NSWindowController with initWithWindowNibName for the custom sheet?

解决方案

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:

Unlike legacy methods, the objects adhere to the standard cocoa memory management rules; it is necessary to keep a strong reference to them by using IBOutlets or holding a reference to the array to prevent the nib contents from being deallocated.

这篇关于折旧的NSNibLoading方法(loadNibFile :, loadNibNamed :,等)的替换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆