如何在主应用程序NIB中设置代理对象? [英] How do I set up a proxy object in the main application NIB?

查看:133
本文介绍了如何在主应用程序NIB中设置代理对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在应用程序NIB文件中设置代理对象。问题是NIB文件是由应用程序自动加载的主应用程序NIB,因此我无法设置 UINibProxiedObjectsKey 字典,如文档中所述。有没有办法在主应用程序NIB中设置代理对象?或者我可以点击加载主应用程序NIB的代码吗?

I would like to set up a proxy object in the application NIB file. The problem is that the NIB file is the main application NIB that gets loaded automatically by the application and therefore I cannot set up the UINibProxiedObjectsKey dictionary as described in the documentation. Is there a way to set up a proxy object in the main application NIB? Or can I tap into the code that loads the main application NIB?

推荐答案

我的主要问题是我试图使用接口Builder作为整个应用程序的依赖注入工具。我有一个必须在代码中创建的对象实例,然后我需要将此实例传递给NIB中的其他对象,因此需要代理对象。最后我发现代理对象的东西太过分了。我创建了一个单独的类,负责将我的对象连接在一起,问题就消失了。

My main problem was that I was trying to use Interface Builder as a dependency injection tool for the whole application. I had an instance of an object that had to be created in code and then I needed to pass this instance to other objects in the NIB, therefore the need for proxy objects. In the end I found the proxy object stuff to be overkill. I created a separate class that takes care of wiring my objects together and the problem disappeared.

这篇关于如何在主应用程序NIB中设置代理对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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