How can I tell if a UITableView contains a specific NSIndexPath?

前端 未结 8 1766
予麋鹿
予麋鹿 2021-02-07 06:27

Here is the code I\'m using:

if (appDelegate.currentMainIndexPath != nil /* && doesPathExistInTableView */)
{
    [tblView scrollToRowAtIndexPath:appDele         


        
8条回答
  •  庸人自扰
    2021-02-07 07:06

    I iterated upon Kamran's answer:

    + (BOOL)isIndexPath:(NSIndexPath *)indexPath inTableView:(UITableView *)tableView {
        if (!indexPath) {
            return NO;
        }
        if (indexPath.section < [tableView numberOfSections]) {
            if (indexPath.row < [tableView numberOfRowsInSection:indexPath.section]) {
                return YES;
            }
        }
        return NO;
    }
    

提交回复
热议问题