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

This commit is contained in:
fengshuo
2022-11-11 17:46:37 +08:00
parent e855f87849
commit c22ede0a13
146 changed files with 515 additions and 371 deletions

View File

@@ -13,6 +13,7 @@
#import "NetImageView.h"
#import "ThemeColor.h"
#import "UIImage+Utils.h"
#import "NSArray+Safe.h"
///Model
#import "UserInfoModel.h"
#import "XPGiftUserInfoModel.h"
@@ -127,7 +128,7 @@
}];
for (int i = 0; i < newArray.count; i++) {
XPGiftUserInfoModel * userInfo = [newArray objectAtIndex:i];
XPGiftUserInfoModel * userInfo = [newArray safeObjectAtIndex1:i];
if (userInfo && userInfo.uid > 0 && userInfo.uid != uid.integerValue) { ///
NSString * uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
if (userInfo.isSelect) {
@@ -162,14 +163,14 @@
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPGiftUserCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftUserCollectionViewCell class]) forIndexPath:indexPath];
XPGiftUserInfoModel * queue = [self.userArray objectAtIndex:indexPath.row];
XPGiftUserInfoModel * queue = [self.userArray safeObjectAtIndex1:indexPath.row];
cell.userInfo = queue;
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
XPGiftUserInfoModel * queue = [self.userArray objectAtIndex:indexPath.row];
XPGiftUserInfoModel * queue = [self.userArray safeObjectAtIndex1:indexPath.row];
queue.isSelect = !queue.isSelect;
[self.collectionView reloadData];
NSString * selectUid = [NSString stringWithFormat:@"%ld", queue.uid];