修复了一些可能数组越界的问题

This commit is contained in:
fengshuo
2023-01-04 14:43:47 +08:00
parent 2a01188251
commit 81d7066ecb
22 changed files with 61 additions and 41 deletions

View File

@@ -11,6 +11,7 @@
#import <MJRefresh/MJRefresh.h>
///Tool
#import "ThemeColor.h"
#import "NSArray+Safe.h"
///Model
#import "XPMineVisitorItemModel.h"
///View
@@ -130,7 +131,7 @@
cell.isFirstItem = indexPath.row == 0;
cell.isLastItem = indexPath.row == self.datasource.count - 1;
cell.delegate = self;
cell.item = [self.datasource objectAtIndex:indexPath.row];
cell.item = [self.datasource safeObjectAtIndex1:indexPath.row];
return cell;
}
@@ -153,7 +154,7 @@
#pragma mark - TTVisitorRecordCellDelegate
- (void)onAvatarClick:(XPMineVisitorTableViewCell *)cell {
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
XPMineVisitorItemModel *item = [self.datasource objectAtIndex:indexPath.row];
XPMineVisitorItemModel *item = [self.datasource safeObjectAtIndex1:indexPath.row];
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
userInfoVC.uid = item.uid;
[self.navigationController pushViewController:userInfoVC animated:YES];
@@ -161,7 +162,7 @@
- (void)onChatClick:(XPMineVisitorTableViewCell *)cell {
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
XPMineVisitorItemModel *item = [self.datasource objectAtIndex:indexPath.row];
XPMineVisitorItemModel *item = [self.datasource safeObjectAtIndex1:indexPath.row];
NSString * sessionId = [NSString stringWithFormat:@"%lld",item.uid];
NIMSession * session = [NIMSession session:sessionId type:NIMSessionTypeP2P];
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];