As a more general approach to solve:
If you use ARC, you need to hold the hold in your objects, or they will be freed for you.
In the above example (suppose you were also intended to assign tableviewObject.datasource), you need some property or member of the class to hold the link to your tableviewObject. For instance:
@interface MyViewController() //anonymous private properties inside your .m @property(nonatomic,strong) UITableView *tableviewObject; @end @implementation MyViewController @synthesize tableviewObject; // rest of your implementation ... @end
This way you will work with self.tableviewObject, but this will remain available as long as the UIViewController is alive with this resource.
The general information to keep in mind is that if you do not want the ARC to release what someone should have used (the link or member property is considered "using" ).
In this regard, the answer thalador / user2413007 is also correct, since the output will refer to the table view in the loaded XIB, which basically has the same result.
source share