How to access items in the main nib from a document nib?

允我心安 提交于 2020-01-17 03:46:10

问题


I'm making an NSDocument-based application in which I have an inspector window. This inspector window is part of Pwnshop.nib which is my main nib. I have another nib called 'Document.nib,' which is the document window. I want to be able to change the inspector based on which document window is the active one, sorta like Interface Builder's inspector. The problem is that I want to access an object in another nib. Note that there are multiple document windows, but only one inspector window.

Could anyone help me?


回答1:


This is essentially the same question as found here. The answer is the same, too. You need to read the documentation and learn about Communicating with Objects and plan your architecture so that you get get to some universally-reachable controller (eg [[NSApp delegate] myInspectorController]) from your NSDocument instances.




回答2:


I can recommend both this and this article (both from Cocoa with Love) for a fundamental lesson in how to structure a Cocoa project. They will answer all of your questions and get you started on a path to building applications the right way.



来源:https://stackoverflow.com/questions/4068938/how-to-access-items-in-the-main-nib-from-a-document-nib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!