Note that there are some explanatory texts on larger screens.

plurals
  1. POIphone programming: Multiple UITableViews reading from the same source?
    primarykey
    data
    text
    <p>This question is related to <a href="https://stackoverflow.com/questions/254354/uitableview-issue-when-using-separate-delegate-datasource">UITableView issue when using separate delegate/dataSource</a>, though I have a different problem. I'm just starting to learn iPhone programming.</p> <p>Basically I have one main view with a table. On the event of a cell click, a sub view with another table is shown.</p> <p>The datasource and delegate for the main view's table are set as files' owner, and I have added the necessary code in there to handle the table data and everything is fine. But, when the second table in the sub-view seems to crash the application, I did the same thing, set the datasource and delegate to the file's owner and repeated the same procedure as for the main view's table. I have no idea why this is happening.</p> <p>The sub-view has its only nib/xib file and its own outlet. If i do not attach any datasource to the subview's table, it takes the data from the main view's table; I don't understand why that is, since I have set the datasource to be the file's owner.</p> <p>For example: the <code>FirstView</code> controller has a table <code>FirstTable</code>, the datasource and delegate are set to the owner of <code>Files</code>. I added the following in <code>FirstView.m</code>:</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 4; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"LibraryListingCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text =@"Table Cell"; return cell; } </code></pre> <p>Everything works perfectly. The moment I repeat this with a second table and a second view, the application crashes saying</p> <pre><code>reason: '-[UISectionRowData tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x69188d0' </code></pre> <p>I have done exactly the same for second table: implemented <code>numberOfRowsInSection</code> and <code>cellForRowAtIndexPatch</code> inside <code>secondview.m</code> and set the second table's delegate and datasource to the file's owner. If I remove the delegate and datasource for the second table, the application doesn't crash but has an empty table in the second view.</p> <p>Any suggestions? or am I missing some key concept here ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload