Reputation: 3813
Is any ViewController which is super class for UITableViewController and UIViewController ? Because I need it for not copy my business logic.
Upvotes: 3
Views: 3422
Reputation: 3725
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.
Upvotes: 2
Reputation: 61
NSObject is a father of most of the classes .. you need to provide datasource and delegate class to implement the table view controller ..
Upvotes: 0
Reputation: 131426
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.
Upvotes: 2
Reputation: 384
Create an NSObject class and write all your Business Logic there and make it as Singletone and call this class where ever you want
Upvotes: -1
Reputation: 12023
Use MVC
pattern in your application and you can create a Model
for storing your business logic and it can communicate with your view through ViewController
object.
Upvotes: 0