问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/2135039/how-do-i-set-up-a-proxy-object-in-the-main-application-nib