Note that there are some explanatory texts on larger screens.

plurals
  1. PO2 UITableView in a UIViewController affecting each other
    primarykey
    data
    text
    <p>I've been going at this for about 3 hours now, and I'm finally throwing in the towel to y'all. I have 2 <code>UITableView</code>in my view, one of which is a forum board to leave comments and what not, and the second <code>UITableView</code> is used to mention people. the issue I am having is that both <code>tableview counts</code> are being affected even if i only want to update just 1 of the tableviews.</p> <p>I set the delegate/datasource in the <code>viewdidload</code></p> <pre><code>self.mentionTableView.delegate = self; self.mentionTableView.dataSource = self; self.mentionTableView.tag = 1; self.forumTable.delegate = self; self.forumTable.dataSource = self; self.forumTable.tag = 2; </code></pre> <p>and if i actually do not load <code>feedArray</code> which is where <code>forumTable</code> gets its data from, the mention portion works perfectly. I've figured out that if <code>matchedNames.count</code>&lt;<code>feedArray.count</code> everything works fine, but if <code>matchedNames.count</code>><code>feedArray.count</code> it crashes and this is the error i get </p> <pre><code>-[__NSCFArray objectAtIndex:]: index (1) beyond bounds (1) </code></pre> <p>which means that i only have 1 item in <code>feedArray</code> and <code>matchedNames</code> has more than one. </p> <p>inside of</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { </code></pre> <p>i have used these codes to try to make it work and still nothing, ive even done combinations of them.</p> <p>1) </p> <pre><code>if ([tableView isEqual: mentionTableView]){ NSLog(@"%@",matchedNames); NSLog(@"%i",matchedNames.count); return [matchedNames count]; } else if([tableView isEqual:forumTable]){ return [feedArray count]; } </code></pre> <p>2)</p> <pre><code>if (tableView == mentionTableView){ NSLog(@"%@",matchedNames); NSLog(@"%i",matchedNames.count); return [matchedNames count]; } else if(tableView == commentTable){ return [feedArray count]; } </code></pre> <p>3)</p> <pre><code> if (tableView.tag == 1){ NSLog(@"%@",matchedNames); NSLog(@"%i",matchedNames.count); return [matchedNames count]; } else if(tableView.tag == 2){ return [feedArray count]; } </code></pre> <p>and I know I didnt have to do the <code>else if</code> but I was just trying to be specific to maybe avoid this issue. </p> <p>this is my <code>cellForRowAtIndexPath</code></p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView.tag == 1){ CGAffineTransform transform = CGAffineTransformMakeRotation(3.14); static NSString *CellIdentifier = @"CellIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.transform = transform; cell.textLabel.text = [self.matchedNames objectAtIndex:indexPath.row]; return cell; } else { static NSString *CellIdentifier = @"commentCell"; commentsCustomCell *cell =(commentsCustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[commentsCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; NSDictionary *feedPost = [feedArray objectAtIndex:indexPath.row]; NSString *checkIFempty = [feedPost objectForKey:@"isForum_empty"]; if (![checkIFempty isEqualToString:@"1"]) { cell.noCommentsLabel.text = nil; } else { cell.noCommentsLabel.text = @"No Comments"; cell.forumComment = nil; } NSString *username =[feedPost objectForKey:@"Username"]; NSString *final_time =[feedPost objectForKey:@"final_time"]; NSString *userIDforPic =[feedPost objectForKey:@"UserID"]; finalComment = [feedPost objectForKey:@"comment"]; cell.forumComment.text = finalComment; return cell; } } </code></pre> <p>if my question is confusing i do apologize, I haven't slept 36 hours. thanks for looking at my question! </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