I’d like to bind my declared properties to controls and views that are created at runtime, much the same way as what happens when using nib / xib files.
The structure of the project is as follows:
- plist file: for setting up a view configuration (buttons, labels, textviews, etc…)
- SOViewController: a class that should be inherited by any class that wants to make use of the layout manager.
- SOView: a very basic view that contains a dictionary of generated controls defined in the plist file
- SOLayoutManager: a singleton responsible for creating the view on behalf of a SOViewController subclass.
Whenever a custom viewController inherits from SOViewController, a plist file with view configuration gets loaded from the bundle. A SOView gets created and all controls are added to the view by the SOLayoutManager (and are also accessible through a dictionary that’s part of the view). The custom view controller should bind the properties with the controls generated from the plist file (the controls that are part of the SOView instance).
My question is as follows: how do I bind the getter and setter methods of the properties contained in my custom view controller with the controls generated in the SOView subclass?
The same way xib’s do it… call
setValue:forKey:If you have something like this
when the
SOLayoutManagercreates the view components it would see if it has anoutletand connect it upYou would need to add the name of the outlet to the plist so it knows what to set it on