Is any ViewController which is super class for UITableViewController and UIViewController ? Because I need it for not copy my business logic.
As the other commenter said, UITableViewController is a fairly thin API on top of a UIViewController. You might be able to start from UIViewController and add the required logic to manage your table view to your custom class. However, there are some things that UITableViewController supports, like static table views and cell prototypes, that would be difficult or impossible to support if you did not use a UITableViewController.
Another alternative would be to create a category of UIViewController and add your extra methods to the category. Category methods are available to the class they are added to and all subclasses, almost as if you added the methods to the base class.
There are a couple of restrictions to category methods however.
i'm currently attempting to accomplish the same (create a superclass to place custom logic for all my VCs to execute). in my particular scenario, i want to track screen views using google analytics' API, which should be called in viewWillAppear. this would require me to place whatever code is required within that method for every view controller.
but i found this gem: method sizzling. thanks to mr. mattt thompson for that!
if you read closely, you will find that you will be able to create a category in which you have the power to replace the existing implementation of a given selector.
however as pointed out by @duncan d, if you seek to just extend behavior, you can simply create a regular category.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With