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

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

@@ -10,6 +10,7 @@
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
///Tool ///Tool
#import "ThemeColor.h" #import "ThemeColor.h"
#import "NSArray+Safe.h"
///View ///View
#import "XPMineDataSkillDataCollectionViewCell.h" #import "XPMineDataSkillDataCollectionViewCell.h"
@@ -78,14 +79,14 @@
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPMineDataSkillDataCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMineDataSkillDataCollectionViewCell class]) forIndexPath:indexPath]; XPMineDataSkillDataCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMineDataSkillDataCollectionViewCell class]) forIndexPath:indexPath];
cell.skillInfo = [self.datasourece objectAtIndex:indexPath.row]; cell.skillInfo = [self.datasourece safeObjectAtIndex1:indexPath.row];
return cell; return cell;
} }
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[collectionView deselectItemAtIndexPath:indexPath animated:YES]; [collectionView deselectItemAtIndexPath:indexPath animated:YES];
if (self.datasourece.count > 0) { if (self.datasourece.count > 0) {
MineSkillCardListInfoModel * skillInfo = [self.datasourece objectAtIndex:indexPath.row]; MineSkillCardListInfoModel * skillInfo = [self.datasourece safeObjectAtIndex1:indexPath.row];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineDataSkillCardTableViewCell:didSelectItem:)]) { if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineDataSkillCardTableViewCell:didSelectItem:)]) {
[self.delegate xPMineDataSkillCardTableViewCell:self didSelectItem:skillInfo]; [self.delegate xPMineDataSkillCardTableViewCell:self didSelectItem:skillInfo];
} }

View File

@@ -12,6 +12,7 @@
#import "ThemeColor.h" #import "ThemeColor.h"
#import "XPMacro.h" #import "XPMacro.h"
#import "UIImage+Utils.h" #import "UIImage+Utils.h"
#import "NSArray+Safe.h"
///View ///View
#import "XPMIneGameCollectionViewCell.h" #import "XPMIneGameCollectionViewCell.h"
@@ -75,7 +76,7 @@
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPMIneGameCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMIneGameCollectionViewCell class]) forIndexPath:indexPath]; XPMIneGameCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMIneGameCollectionViewCell class]) forIndexPath:indexPath];
LittleGameInfoModel * item = [self.datasource objectAtIndex:indexPath.row]; LittleGameInfoModel * item = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.gameModel = item; cell.gameModel = item;
return cell; return cell;
} }
@@ -83,7 +84,7 @@
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[collectionView deselectItemAtIndexPath:indexPath animated:YES]; [collectionView deselectItemAtIndexPath:indexPath animated:YES];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineGameTableViewCell:didSelectItem:)]) { if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineGameTableViewCell:didSelectItem:)]) {
LittleGameInfoModel * model = [self.datasource objectAtIndex:indexPath.row]; LittleGameInfoModel * model = [self.datasource safeObjectAtIndex1:indexPath.row];
[self.delegate xPMineGameTableViewCell:self didSelectItem:model]; [self.delegate xPMineGameTableViewCell:self didSelectItem:model];
} }
} }

View File

@@ -11,6 +11,7 @@
///Tool ///Tool
#import "ThemeColor.h" #import "ThemeColor.h"
#import "XPMacro.h" #import "XPMacro.h"
#import "NSArray+Safe.h"
///View ///View
#import "XPMineHeadItemCollectionViewCell.h" #import "XPMineHeadItemCollectionViewCell.h"
#import "XPMineHeadFunctionItemLayout.h" #import "XPMineHeadFunctionItemLayout.h"
@@ -61,7 +62,7 @@
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPMineHeadItemCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMineHeadItemCollectionViewCell class]) forIndexPath:indexPath]; XPMineHeadItemCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMineHeadItemCollectionViewCell class]) forIndexPath:indexPath];
XPMineFuntionItemModel * item = [self.datasource objectAtIndex:indexPath.row]; XPMineFuntionItemModel * item = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.itemModel = item; cell.itemModel = item;
return cell; return cell;
} }
@@ -69,7 +70,7 @@
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[collectionView deselectItemAtIndexPath:indexPath animated:YES]; [collectionView deselectItemAtIndexPath:indexPath animated:YES];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineHeadItemTableViewCell:didSelectItem:)]) { if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineHeadItemTableViewCell:didSelectItem:)]) {
XPMineFuntionItemModel * model = [self.datasource objectAtIndex:indexPath.row]; XPMineFuntionItemModel * model = [self.datasource safeObjectAtIndex1:indexPath.row];
[self.delegate xPMineHeadItemTableViewCell:self didSelectItem:model]; [self.delegate xPMineHeadItemTableViewCell:self didSelectItem:model];
} }
} }

View File

@@ -12,6 +12,7 @@
#import "ThemeColor.h" #import "ThemeColor.h"
#import "XPMacro.h" #import "XPMacro.h"
#import "Api+DressUp.h" #import "Api+DressUp.h"
#import "NSArray+Safe.h"
///Model ///Model
#import "HomeSearchResultModel.h" #import "HomeSearchResultModel.h"
///View ///View
@@ -91,7 +92,7 @@
if (cell == nil) { if (cell == nil) {
cell = [[XPDressShopSearchTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPDressShopSearchTableViewCell class])]; cell = [[XPDressShopSearchTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPDressShopSearchTableViewCell class])];
} }
HomeSearchResultModel * resultModel = [self.datasource objectAtIndex:indexPath.row]; HomeSearchResultModel * resultModel = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.data = resultModel; cell.data = resultModel;
cell.delegate = self; cell.delegate = self;
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
@@ -105,7 +106,7 @@
#pragma mark - XPDressShopSearchTableViewCellDelegate #pragma mark - XPDressShopSearchTableViewCellDelegate
- (void)xPDressShopSearchTableViewCellSendButtonClick:(XPDressShopSearchTableViewCell *)cell { - (void)xPDressShopSearchTableViewCellSendButtonClick:(XPDressShopSearchTableViewCell *)cell {
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
HomeSearchResultModel * resultModel = [self.datasource objectAtIndex:indexPath.row]; HomeSearchResultModel * resultModel = [self.datasource safeObjectAtIndex1:indexPath.row];
[self showLoading]; [self showLoading];
[Api requestSendDress:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { [Api requestSendDress:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
[self hideHUD]; [self hideHUD];

View File

@@ -10,6 +10,7 @@
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
///Tool ///Tool
#import "XPMacro.h" #import "XPMacro.h"
#import "NSArray+Safe.h"
///View ///View
#import "XPMineDressEmptyTableViewCell.h" #import "XPMineDressEmptyTableViewCell.h"
#import "XPDressUpShopCardTableViewCell.h" #import "XPDressUpShopCardTableViewCell.h"
@@ -154,7 +155,7 @@
if (cell == nil) { if (cell == nil) {
cell = [[XPDressUpShopCardTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPDressUpShopCardTableViewCell class])]; cell = [[XPDressUpShopCardTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPDressUpShopCardTableViewCell class])];
} }
cell.nobleCardModel = [self.datasource objectAtIndex:indexPath.row]; cell.nobleCardModel = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.delegate = self; cell.delegate = self;
return cell; return cell;
} }

View File

@@ -10,6 +10,7 @@
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
///Tool ///Tool
#import "XPMacro.h" #import "XPMacro.h"
#import "NSArray+Safe.h"
///View ///View
#import "XPMineDressEmptyCollectionViewCell.h" #import "XPMineDressEmptyCollectionViewCell.h"
#import "XPDressUpShopCollectionViewCell.h" #import "XPDressUpShopCollectionViewCell.h"
@@ -145,7 +146,7 @@
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.datasource.count > 0) { if (self.datasource.count > 0) {
XPDressUpShopCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPDressUpShopCollectionViewCell class]) forIndexPath:indexPath]; XPDressUpShopCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPDressUpShopCollectionViewCell class]) forIndexPath:indexPath];
cell.dressUpModel = [self.datasource objectAtIndex:indexPath.row]; cell.dressUpModel = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.delegate = self; cell.delegate = self;
return cell; return cell;
} }

View File

@@ -17,6 +17,7 @@
#import "XPMacro.h" #import "XPMacro.h"
#import "UIImage+Utils.h" #import "UIImage+Utils.h"
#import "AccountInfoStorage.h" #import "AccountInfoStorage.h"
#import "NSArray+Safe.h"
///Model ///Model
#import "ActivityInfoModel.h" #import "ActivityInfoModel.h"
#import "WalletInfoModel.h" #import "WalletInfoModel.h"
@@ -219,7 +220,7 @@
#pragma mark - SDCycleScrollViewDelegate #pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index { - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
if (self.activityList.count > index) { if (self.activityList.count > index) {
ActivityInfoModel * info = [self.activityList objectAtIndex:index]; ActivityInfoModel * info = [self.activityList safeObjectAtIndex1:index];
if (info.skipType == ActivitySkipType_Room) { if (info.skipType == ActivitySkipType_Room) {
[XPRoomViewController openRoom:info.skipUri viewController:self.navigationController]; [XPRoomViewController openRoom:info.skipUri viewController:self.navigationController];
} else if(info.skipType == ActivitySkipType_Web) { } else if(info.skipType == ActivitySkipType_Web) {

View File

@@ -10,6 +10,7 @@
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
///Tool ///Tool
#import "XPMacro.h" #import "XPMacro.h"
#import "NSArray+Safe.h"
///View ///View
#import "XPMineDressBubbleCollectionViewCell.h" #import "XPMineDressBubbleCollectionViewCell.h"
#import "XPMineDressEmptyCollectionViewCell.h" #import "XPMineDressEmptyCollectionViewCell.h"
@@ -93,7 +94,7 @@
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.datasource.count > 0) { if (self.datasource.count > 0) {
XPMineDressBubbleCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMineDressBubbleCollectionViewCell class]) forIndexPath:indexPath]; XPMineDressBubbleCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMineDressBubbleCollectionViewCell class]) forIndexPath:indexPath];
cell.bubbleModel = [self.datasource objectAtIndex:indexPath.row]; cell.bubbleModel = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.delegate = self; cell.delegate = self;
return cell; return cell;
} }

View File

@@ -10,6 +10,7 @@
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
///Tool ///Tool
#import "XPMacro.h" #import "XPMacro.h"
#import "NSArray+Safe.h"
///View ///View
#import "XPMineHeadwearTableViewCell.h" #import "XPMineHeadwearTableViewCell.h"
#import "XPMineCarTableViewCell.h" #import "XPMineCarTableViewCell.h"
@@ -151,7 +152,7 @@
if (cell == nil) { if (cell == nil) {
cell = [[XPMineHeadwearTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineHeadwearTableViewCell class])]; cell = [[XPMineHeadwearTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineHeadwearTableViewCell class])];
} }
cell.headwearModel = [self.datasource objectAtIndex:indexPath.row]; cell.headwearModel = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.delegate = self; cell.delegate = self;
return cell; return cell;
} else if(self.type == DressUpListType_Car) { } else if(self.type == DressUpListType_Car) {
@@ -159,7 +160,7 @@
if (cell == nil) { if (cell == nil) {
cell = [[XPMineCarTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineCarTableViewCell class])]; cell = [[XPMineCarTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineCarTableViewCell class])];
} }
cell.carInfo = [self.datasource objectAtIndex:indexPath.row]; cell.carInfo = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.delegate = self; cell.delegate = self;
return cell; return cell;
} else if (self.type == DressUpListType_Noble) { } else if (self.type == DressUpListType_Noble) {
@@ -167,7 +168,7 @@
if (cell == nil) { if (cell == nil) {
cell = [[XPMineNobleCardTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineNobleCardTableViewCell class])]; cell = [[XPMineNobleCardTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineNobleCardTableViewCell class])];
} }
cell.nobleCardModel = [self.datasource objectAtIndex:indexPath.row]; cell.nobleCardModel = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.delegate = self; cell.delegate = self;
return cell; return cell;
} else { } else {
@@ -175,7 +176,7 @@
if (cell == nil) { if (cell == nil) {
cell = [[XPMineNameplateTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineNameplateTableViewCell class])]; cell = [[XPMineNameplateTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineNameplateTableViewCell class])];
} }
cell.nameplateModel = [self.datasource objectAtIndex:indexPath.row]; cell.nameplateModel = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.delegate = self; cell.delegate = self;
return cell; return cell;
} }

View File

@@ -14,6 +14,7 @@
///Tool ///Tool
#import "ThemeColor.h" #import "ThemeColor.h"
#import "Api+DressUp.h" #import "Api+DressUp.h"
#import "NSArray+Safe.h"
///Model ///Model
#import "ActivityInfoModel.h" #import "ActivityInfoModel.h"
///View ///View
@@ -141,7 +142,7 @@
#pragma mark - SDCycleScrollViewDelegate #pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index { - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
if (self.activityList.count > index) { if (self.activityList.count > index) {
ActivityInfoModel * info = [self.activityList objectAtIndex:index]; ActivityInfoModel * info = [self.activityList safeObjectAtIndex1:index];
if (info.skipType == ActivitySkipType_Room) { if (info.skipType == ActivitySkipType_Room) {
[XPRoomViewController openRoom:info.skipUri viewController:self.navigationController]; [XPRoomViewController openRoom:info.skipUri viewController:self.navigationController];
} else if(info.skipType == ActivitySkipType_Web) { } else if(info.skipType == ActivitySkipType_Web) {

View File

@@ -80,14 +80,14 @@
if (cell == nil) { if (cell == nil) {
cell = [[XPMatchManageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMatchManageTableViewCell class])]; cell = [[XPMatchManageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMatchManageTableViewCell class])];
} }
XPMineItemModel * item = [self.matchItemArray objectAtIndex:indexPath.row]; XPMineItemModel * item = [self.matchItemArray safeObjectAtIndex1:indexPath.row];
cell.itemModel = item; cell.itemModel = item;
return cell; return cell;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES]; [tableView deselectRowAtIndexPath:indexPath animated:YES];
XPMineItemModel * model = [self.matchItemArray objectAtIndex:indexPath.row]; XPMineItemModel * model = [self.matchItemArray safeObjectAtIndex1:indexPath.row];
[self pushViewControllerWithType:model.type]; [self pushViewControllerWithType:model.type];
} }

View File

@@ -15,6 +15,7 @@
#import "YYUtility.h" #import "YYUtility.h"
///Tool ///Tool
#import "ThemeColor.h" #import "ThemeColor.h"
#import "NSArray+Safe.h"
///Model ///Model
#import "UserInfoModel.h" #import "UserInfoModel.h"
///View ///View
@@ -139,7 +140,7 @@
cell.isEdit = NO; cell.isEdit = NO;
} else { } else {
if (self.datasource.count > 0) { if (self.datasource.count > 0) {
cell.photo = [self.datasource objectAtIndex:indexPath.row - 1]; cell.photo = [self.datasource safeObjectAtIndex1:indexPath.row - 1];
cell.isEdit = self.isEdit; cell.isEdit = self.isEdit;
} }
} }

View File

@@ -14,6 +14,7 @@
#import "TTPopup.h" #import "TTPopup.h"
#import "YYUtility.h" #import "YYUtility.h"
#import "XPMacro.h" #import "XPMacro.h"
#import "NSArray+Safe.h"
///Model ///Model
#import "XPMineUserInfoEditModel.h" #import "XPMineUserInfoEditModel.h"
#import "UserInfoModel.h" #import "UserInfoModel.h"
@@ -137,7 +138,7 @@
} }
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
XPMineUserInfoEditModel * model = [self.datasouce objectAtIndex:indexPath.row]; XPMineUserInfoEditModel * model = [self.datasouce safeObjectAtIndex1:indexPath.row];
if (model.type == XPMineUserInfoEditType_Avatar) { if (model.type == XPMineUserInfoEditType_Avatar) {
return 60; return 60;
} else { } else {
@@ -150,14 +151,14 @@
if (cell == nil) { if (cell == nil) {
cell = [[XPMineUserInfoEditTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineUserInfoEditTableViewCell class])]; cell = [[XPMineUserInfoEditTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineUserInfoEditTableViewCell class])];
} }
XPMineUserInfoEditModel * model = [self.datasouce objectAtIndex:indexPath.row]; XPMineUserInfoEditModel * model = [self.datasouce safeObjectAtIndex1:indexPath.row];
cell.itmeModel = model; cell.itmeModel = model;
return cell; return cell;
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES]; [tableView deselectRowAtIndexPath:indexPath animated:YES];
XPMineUserInfoEditModel * model = [self.datasouce objectAtIndex:indexPath.row]; XPMineUserInfoEditModel * model = [self.datasouce safeObjectAtIndex1:indexPath.row];
switch (model.type) { switch (model.type) {
case XPMineUserInfoEditType_Nick: case XPMineUserInfoEditType_Nick:
{ {

View File

@@ -11,6 +11,7 @@
///Tool ///Tool
#import "ThemeColor.h" #import "ThemeColor.h"
#import "XPMacro.h" #import "XPMacro.h"
#import "NSArray+Safe.h"
///View ///View
#import "XPMineUserInfoGiftWallCollectionViewCell.h" #import "XPMineUserInfoGiftWallCollectionViewCell.h"
#import "XPGuildEmptyCollectionViewCell.h" #import "XPGuildEmptyCollectionViewCell.h"
@@ -59,7 +60,7 @@
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.datasource.count > 0) { if (self.datasource.count > 0) {
XPMineUserInfoGiftWallCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMineUserInfoGiftWallCollectionViewCell class]) forIndexPath:indexPath]; XPMineUserInfoGiftWallCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMineUserInfoGiftWallCollectionViewCell class]) forIndexPath:indexPath];
UserGiftWallInfoModel * giftInfo = [self.datasource objectAtIndex:indexPath.row]; UserGiftWallInfoModel * giftInfo = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.giftInfo = giftInfo; cell.giftInfo = giftInfo;
return cell; return cell;

View File

@@ -10,6 +10,7 @@
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
///Tool ///Tool
#import "XPMacro.h" #import "XPMacro.h"
#import "NSArray+Safe.h"
///View ///View
#import "XPMineDataGiftCollectionViewCell.h" #import "XPMineDataGiftCollectionViewCell.h"
#import "XPMineUserInfoEmptyCollectionViewCell.h" #import "XPMineUserInfoEmptyCollectionViewCell.h"
@@ -53,7 +54,7 @@
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.datasource.count > 0) { if (self.datasource.count > 0) {
XPMineDataGiftCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMineDataGiftCollectionViewCell class]) forIndexPath:indexPath]; XPMineDataGiftCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMineDataGiftCollectionViewCell class]) forIndexPath:indexPath];
cell.giftInfo = [self.datasource objectAtIndex:indexPath.row]; cell.giftInfo = [self.datasource safeObjectAtIndex1:indexPath.row];
return cell; return cell;
} }

View File

@@ -17,6 +17,7 @@
#import "UIImage+ImageEffects.h" #import "UIImage+ImageEffects.h"
#import "UIImage+Utils.h" #import "UIImage+Utils.h"
#import "NetImageView.h" #import "NetImageView.h"
#import "NSArray+Safe.h"
///Model ///Model
#import "UserInfoModel.h" #import "UserInfoModel.h"
@@ -265,7 +266,7 @@
#pragma mark - SDPhotoBrowserDelegate #pragma mark - SDPhotoBrowserDelegate
- (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index { - (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index {
NSString * photoUrl = [self.imageUrls objectAtIndex:index]; NSString * photoUrl = [self.imageUrls safeObjectAtIndex1:index];
return [NSURL URLWithString:photoUrl]; return [NSURL URLWithString:photoUrl];
} }
@@ -276,7 +277,7 @@
#pragma mark - SDCycleScrollViewDelegate #pragma mark - SDCycleScrollViewDelegate
-(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index { -(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index {
[self.pageButton setTitle:[NSString stringWithFormat:@"%ld/%lu",(index + 1), (unsigned long)self.imageUrls.count] forState:UIControlStateNormal]; [self.pageButton setTitle:[NSString stringWithFormat:@"%ld/%lu",(index + 1), (unsigned long)self.imageUrls.count] forState:UIControlStateNormal];
UserPhoto * photo = [self.userPhtotArray objectAtIndex:index]; UserPhoto * photo = [self.userPhtotArray safeObjectAtIndex1:index];
self.reviewIcon.hidden = !photo.isReview; self.reviewIcon.hidden = !photo.isReview;
} }
@@ -358,7 +359,7 @@
} }
if (self.userInfo.privatePhoto.count > 0) { if (self.userInfo.privatePhoto.count > 0) {
for (int i = 0; i < self.userInfo.privatePhoto.count; i++) { for (int i = 0; i < self.userInfo.privatePhoto.count; i++) {
UserPhoto * photo = [self.userInfo.privatePhoto objectAtIndex:i]; UserPhoto * photo = [self.userInfo.privatePhoto safeObjectAtIndex1:i];
if (photo.photoUrl.length > 0) { if (photo.photoUrl.length > 0) {
[self.userPhtotArray addObject:photo]; [self.userPhtotArray addObject:photo];
[imageUrls addObject:photo.photoUrl]; [imageUrls addObject:photo.photoUrl];

View File

@@ -13,6 +13,7 @@
#import "UIImage+Utils.h" #import "UIImage+Utils.h"
#import "UIButton+EnlargeTouchArea.h" #import "UIButton+EnlargeTouchArea.h"
#import "ThemeColor.h" #import "ThemeColor.h"
#import "NSArray+Safe.h"
///Model ///Model
#import "MineSkillCardListInfoModel.h" #import "MineSkillCardListInfoModel.h"
#import "XPSkillCardPlayerManager.h" #import "XPSkillCardPlayerManager.h"
@@ -75,7 +76,7 @@
if (!self.isPlaying) { if (!self.isPlaying) {
if(self.voiceInfo.propVals.count) { if(self.voiceInfo.propVals.count) {
// NSString *fileName = [[self.voiceInfo.name componentsSeparatedByString:@"/"] lastObject]; // NSString *fileName = [[self.voiceInfo.name componentsSeparatedByString:@"/"] lastObject];
NSString * url = [self.voiceInfo.propVals objectAtIndex:0]; NSString * url = [self.voiceInfo.propVals safeObjectAtIndex1:0];
NSArray * nameArray = [url componentsSeparatedByString:@"/"]; NSArray * nameArray = [url componentsSeparatedByString:@"/"];
NSString * fileName = @"daeplay"; NSString * fileName = @"daeplay";
if (nameArray.count > 0) { if (nameArray.count > 0) {

View File

@@ -10,6 +10,7 @@
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
///Tool ///Tool
#import "ThemeColor.h" #import "ThemeColor.h"
#import "NSArray+Safe.h"
///Model ///Model
#import "XPMineAnchorFansTeamModel.h" #import "XPMineAnchorFansTeamModel.h"
///View ///View
@@ -79,7 +80,7 @@
if (cell == nil) { if (cell == nil) {
cell = [[XPMineAnchorFansTeamTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineAnchorFansTeamTableViewCell class])]; cell = [[XPMineAnchorFansTeamTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineAnchorFansTeamTableViewCell class])];
} }
cell.item = [self.datasource objectAtIndex:indexPath.row]; cell.item = [self.datasource safeObjectAtIndex1:indexPath.row];
return cell; return cell;
} }
@@ -92,7 +93,7 @@
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
XPMineAnchorFansTeamModel *item = [self.datasource objectAtIndex:indexPath.row]; XPMineAnchorFansTeamModel *item = [self.datasource safeObjectAtIndex1:indexPath.row];
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init]; XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
userInfoVC.uid = item.teamUid; userInfoVC.uid = item.teamUid;
[self.navigationController pushViewController:userInfoVC animated:YES]; [self.navigationController pushViewController:userInfoVC animated:YES];

View File

@@ -151,7 +151,7 @@
if (cell == nil) { if (cell == nil) {
cell = [[XPMineFootPrintTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineFootPrintTableViewCell class])]; cell = [[XPMineFootPrintTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineFootPrintTableViewCell class])];
} }
cell.item = [self.datasource objectAtIndex:indexPath.row]; cell.item = [self.datasource safeObjectAtIndex1:indexPath.row];
return cell; return cell;
} }
@@ -167,12 +167,12 @@
[tableView setEditing:NO animated:YES]; [tableView setEditing:NO animated:YES];
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
UIContextualAction *deleteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) { UIContextualAction *deleteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
XPMineFootPrintModel *item = [weakSelf.datasource objectAtIndex:indexPath.row]; XPMineFootPrintModel *item = [weakSelf.datasource safeObjectAtIndex1:indexPath.row];
[weakSelf.presenter cleanFootPrint:item.roomUid]; [weakSelf.presenter cleanFootPrint:item.roomUid];
completionHandler(true); completionHandler(true);
}]; }];
UIContextualAction *collectAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:@"收藏" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) { UIContextualAction *collectAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleNormal title:@"收藏" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
XPMineFootPrintModel *item = [weakSelf.datasource objectAtIndex:indexPath.row]; XPMineFootPrintModel *item = [weakSelf.datasource safeObjectAtIndex1:indexPath.row];
[weakSelf.presenter collectRoomWithRoomUid:item.roomUid]; [weakSelf.presenter collectRoomWithRoomUid:item.roomUid];
completionHandler(true); completionHandler(true);
}]; }];

View File

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

View File

@@ -11,6 +11,7 @@
#import <AVFoundation/AVFoundation.h> #import <AVFoundation/AVFoundation.h>
#import "XPMacro.h" #import "XPMacro.h"
#import "ThemeColor.h" #import "ThemeColor.h"
#import "NSArray+Safe.h"
@interface XPPermissionCell : UITableViewCell @interface XPPermissionCell : UITableViewCell
@@ -194,9 +195,9 @@
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger section = indexPath.section; NSInteger section = indexPath.section;
XPPermissionCell * cell = [[XPPermissionCell alloc] init]; XPPermissionCell * cell = [[XPPermissionCell alloc] init];
cell.icon.image = [UIImage imageNamed:[self.permissionIcons objectAtIndex:section]]; cell.icon.image = [UIImage imageNamed:[self.permissionIcons safeObjectAtIndex1:section]];
cell.name.text = [self.permissionNames objectAtIndex:section]; cell.name.text = [self.permissionNames safeObjectAtIndex1:section];
cell.tip.text = [self.permissionTips objectAtIndex:section]; cell.tip.text = [self.permissionTips safeObjectAtIndex1:section];
return cell; return cell;
} }

View File

@@ -12,6 +12,7 @@
#import "XPWebViewController.h" #import "XPWebViewController.h"
#import "XPPermissionsViewController.h" #import "XPPermissionsViewController.h"
#import "XPHtmlUrl.h" #import "XPHtmlUrl.h"
#import "NSArray+Safe.h"
@interface XPPrivacyViewController ()<UITableViewDelegate, UITableViewDataSource> @interface XPPrivacyViewController ()<UITableViewDelegate, UITableViewDataSource>
@@ -54,7 +55,7 @@
cell = [[XPMineSettingTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineSettingTableViewCell class])]; cell = [[XPMineSettingTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineSettingTableViewCell class])];
} }
cell.itemModel = [self.datasource objectAtIndex:indexPath.row]; cell.itemModel = [self.datasource safeObjectAtIndex1:indexPath.row];
return cell; return cell;
} }