the class ref says:
If you use the standard init method to initialize a UITableViewController object, a table view in the plain style is created.
i do not understand, where this behaviour comes from - i would like to see i in some code or api but
UITableViewController has no init in its api
how could some base class' init know about a suitable default style for a derived class?
thanks for every hint
Every object has an init
method, but a lot of classes have a so-called designated initializer. That is the main initializer, and the others are merely convenience methods calling that designated initializer.
According to that doc, in this case the init
method probably looks something like this:
- (id)init
{
return [self initWithStyle:UITableViewStylePlain];
}
Methods from a superclass do not appear in the documentation of the derived class, except if the derived class overrides it and has something important to say about it. That's why you don't see init
documented in UITableViewController
, it's part of NSObject
from which UITableViewController derives (through UIScrollView -> UIView -> UIResponder -> NSObject).
As for the second part of your question: a base class can (should) never know anything about derived classes. A derived class that wants a different default style simple overrides init
again.
in UITableViewController.m
- (id) init
{
return [self initWithStyle:UITableViewStylePlain];
}
The init
method will call the designated initializer.
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