After doing some research in apple documentation here's what I found.
In UIViewController , the view property
@property(nonatomic, retain) UIView *view
means the view that the controller manages.
and
In UITableViewController , the tableView property
@property(nonatomic, retain) UITableView *tableView
means the tableView that the controller manages.
Since UITableViewController is the subclass of UIViewController , it will inherit the view property. So when I'm writing codes in UITableViewController subclass file, there's these 2 properties that always confuses me and I'm not sure when to use it. Please explain. Thanks.
For a UITableViewController
, the tableView
and view
properties are the same.
Use the tableView
property in your table view controller when you need to access the table view and make use of various UITableView
properties and methods. Or even if you need plain old UIView
methods.
It's fine to use the view
property in cases where you only need UIView
properties and methods. It's really a matter of taste which property to use in this case.
In case of UItableViewController
both are same but different in you have UITableView
in the UIViewController
then view
property will refer to UIViewController
and tableview
will refer to UITableView
. To avoid confusion always use tableview
in case of UITableViewController
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.