I've a view with few UITableView/s and UILabel/s. I'm creating them programmatically (i.e not using NIB).
I've consolidated tableView and label creation in a method with signature:
- (void) CreateTableView:(UITableView*) outTableView andLabel:(UILabel*)OutLabel AtFrame:(CGRect) frame{
CGRect labelFrame = frame;
labelFrame.origin.x = LABEL_LEFT_ALIGNMENT;
labelFrame.origin.y -= LABEL_TOP_ALIGNMENT;
labelFrame.size.height = LABEL_HEIGHT;
outLabel = [[UILabel alloc] initWithFrame:labelFrame];
[[self view] addSubview:outLabel];
outTableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStyleGrouped];
[outTableView setDataSource:self];
[outTableView setDelegate:self];
[[self view] addSubview:outTableView];
}
Here, outTableView and outLabel are output parameters. That is, after completion of method , caller will be using outTableView and outLabel.
My app has 3 tableview instance variables -- tableView1, tableView2, tableView3. And three label instance variables. View controller (caller) calls like:
[self CreateTableView:tableView1 andLabel:label1 AtFrame:frame1];
[self CreateTableView:tableView2 andLabel:label2 AtFrame:frame2];
[self CreateTableView:tableView3 andLabel:label3 AtFrame:frame3];
After completion of this method, UILabel* are rendered on screen, caller able to use UILabel* object. Strangely, that is not the case with UITableView* object.
Any idea, why there is different behaviour?
Note: My application is ARC enabled.