I have a few questions regarding the proxy objects of a NIB file, specifically in regards to the File's Owner object.
The File's Owner object is a placeholder instance which represents some instance of a class outside the NIB file that will soon substitute this tentative instance. From what I understand, NIB files and XIB files are lazy loaded. Does this mean the placeholder instance (before it is substituted by the "real" class's instance) is already an instance (not a type) even before the NIB files are called?
What is this placeholder instance an instance of?
The File's Owner object is configured with a custom class, say ViewController. Why do you have to specify the owner again when you load this NIB file?
Bundle.main.loadNibNamed("SomeNIBFile", owner: self )
This is best asked over at the Apple Developer forums, et al, since this a question about the Apple frameworks, not Swift.
You really need to look at the Apple programming guides or some reference on Apple UI programming that explains what the proxy objects (
Application, etc.) do in a XIB/Storyboard based application, and the whole initialization process and XIB loading process. The XIB file is an XML files that describes the object graph that gets instantiated during a NIB loading process. There is no placeholder instance, except in the object graph in XML. The
File Owner proxy object in the XIB is used by Interface Builder to allow connections to the outlets and action methods defined in a potential instance of the identified class type designated as the
File Owner class. When you use a method such as
owner instance is associated as the
File Owner for the instance of the NIB you are loading. Identifying a class as the
File Owner class allows Interface Builder to access the definitions of the outlets and action methods to allow interconnecting the object graph.
Thank you for your answer. Could you explain what you mean by above? As far as I understand, the File Owner object is something to be substitute by the instance of the object that's going to call the NIB/XIB. The Document Outline of the editor pane also shows the File's Owner as one of the "Placeholders".
As I said above, Interface Builder needs to know what the outlets and actions that are defined in the type that will be the type of an instance object (there can be more than one) that will "own" an instance of the object graph loaded from NIB file when asked. The
File Owner proxy is an Interface Builder construct to represent potential instances of objects that will instantiate an instance of the object graph that allows the user to connect action methods and outlets defined in the object graph to the
File Owner instance that loads the NIB/XIB (again, there can be more than one).
Your best bet is to find the Apple programming guides or look into other resources to understand what Interface Builder does, and how NIB files are actually loaded and instantiated.
The editor pane you are referring to is Interface Builder. You might want to look at the Interface Builder documentation in Xcode to get started.