in the storyboard there is a object entity that can be added to a view controller. My problem is i am not sure of its purpose. What is its usefulness and also can you show its usage and how the same thing can be done programatically. I've tried dragging the object template over to a viewController but i dont know what to do with it afterwards. I'll provide a screenshot of exactly what im looking for since its in the interface builder of xcode:
Asked
Active
Viewed 829 times
1 Answers
3
This is useful to add an instance of a custom class. After you drag the Object into the document, you change its class on the Identity inspector. When the storyboard is loaded, an instance of that class will be created.
It's relatively uncommon to need to do it. You might add some custom controller object, but usually such responsibilities would be handled by the view controller or array/tree controllers. If you don't see a need, then don't worry about it. If, someday, you do find a need, well, then you'll know why it's possible.

Ken Thomases
- 88,520
- 7
- 116
- 154
-
i inherited code thats already using it in a containing controller. could you give a specific example how it can be used ? – j2emanue Mar 26 '15 at 19:33
-
If you inherited code which is using it, then you presumably already have an example of how it can be used. As another example, if you create an app using NIBs rather than storyboards, MainMenu.xib contains the application delegate object. It's just a version of this Object from the library, set to be an instance of the `AppDelegate` class from the template project. It is connected as the `delegate` of the File's Owner (which will be the application object because that's what loads MainMenu.nib). It has a `window` outlet, which is connected to the window that's also present in the NIB. – Ken Thomases Mar 26 '15 at 19:47
-
Is this a form of dependency injection? kind of like dagger 2 in Android – Brendon Cheung Jan 15 '19 at 15:57