Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

johnmerlino

macrumors member
Original poster
Oct 22, 2011
81
0
Hey all,

I have a uiview controller, with 4 uiviews and 3 of the 4 uiviews have table views. They are all connected to remoteTableViews:

Code:
@property (strong, nonatomic) IBOutletCollection(UITableView) NSArray *remoteTableViews;

So all of the table views properly display for their respective uiviews. The problem is some of the table views cells are not populated with data. I believe it has to do with the fact that when the tableView callback is invoked on my uiviewcontroller, it seems to pass only 1 of the 3 table views:

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *CellIdentifier = @"CellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    if (self.fenceIsActive)
    {
        cell.imageView.image = [UIImage imageNamed:@"checked.gif"];        
    }
    else {
        cell.imageView.image = [UIImage imageNamed:@"unchecked.jpg"];
    }
    UILabel *cellLabel = (UILabel *)[cell viewWithTag:1];
    [cellLabel setText:[self displayLabelFor:indexPath.row]];
	return cell;
}

Is there a way to pass all 3 table views to a callback so that all 3 table views get populated with the same data?
 
Last edited by a moderator:
Give them all the same data source object.

Or give each one its own data source object, but that object connects to a single underlying model object.
 
Give them all the same data source object.

Or give each one its own data source object, but that object connects to a single underlying model object.

My data source is stored in NSArray. I select table view and in connections inspector, i drag dataSource of the table view onto the nsarray instance var in .h but it doesnt connect.
 
My data source is stored in NSArray. I select table view and in connections inspector, i drag dataSource of the table view onto the nsarray instance var in .h but it doesnt connect.

You don't have to connect it with the ivar. Your view controller has to implement the UITableViewDataSource and UITableViewDelegate (if required) protocol.



Then you can drag from the table view to File's Owner in Interface Builder, selecting dataSource.

Alternatively, in your view controller's viewDidLoad you can do this:

Code:
[self.firstTableView setDataSource:self];
[self.secondTableView setDataSource:self];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.