Overriding properties of child view controller vs setting them via parent view controller
Posted
by robinjam
on Stack Overflow
See other posts from Stack Overflow
or by robinjam
Published on 2010-02-18T16:03:15Z
Indexed on
2010/04/14
22:03 UTC
Read the original article
Hit count: 294
If you want to modify the default behaviour of a View Controller by changing the value of one of its properties, is it considered better form to
instantiate the class and set its property directly, or
subclass it and override the property?
With the former it would become the parent View Controller's responsibility to configure its children, whereas with the latter the children would effectively configure themselves.
EDIT: Some more information:
The class I am referring to is FetchedTableViewController, a subclass of UITableViewController that I made to display the results of a Core Data fetch operation.
There are two places I want to display the results of a fetch, and they each have different fetch requests.
I'm trying to decide whether it's better to create a subclass for each one, and override the fetchRequest property, or make it the responsibility of the parent controller to set the fetchRequest property for its children.
© Stack Overflow or respective owner