From fc7a556b6c8c9a980780b195bc54df22437cd800 Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Thu, 29 Dec 2022 17:15:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4=E5=B4=A9=E6=BA=83=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios.xcodeproj/project.pbxproj | 12 - xplan-ios/Base/MVP/Api/Api.m | 11 +- .../Home/View/XPHomeLivesViewController.m | 5 +- .../View/XPRoomSearchRecordViewController.m | 6 +- .../SessionList/SessionListViewController.m | 11 +- .../Noble/View/XPNobleRankViewController.m | 3 +- .../Recharge/XPMineRechargeViewController.m | 3 +- .../View/SubViews/XPSkillCardSelectPropView.m | 13 +- .../Mine/View/XPMineFootPrintViewController.m | 3 +- .../FaceView/View/XPRoomFaceViewController.m | 4 +- .../SendGiftView/View/XPGiftHeadTypeView.m | 3 +- .../SendGiftView/View/XPGraffitiGiftView.m | 4 +- .../XPRoomActivityContainerView.m | 13 +- .../View/XPAnchorFansTaskViewController.m | 3 +- .../View/AnimationView/XPRoomAnimationView.m | 30 +- .../XPRoomFunctionContainerView.m | 6 +- .../View/CandyTree/View/XPCandyTreeMoreView.m | 2 +- .../Presenter/Category/NSString+RW.h | 270 --------- .../Presenter/Category/NSString+RW.m | 522 ------------------ .../Presenter/Category/UIColor+RW.h | 93 ---- .../Presenter/Category/UIColor+RW.m | 81 --- .../View/LittleGame/Presenter/SudCommon.m | 5 +- .../XPRoomQuickMessageContainView.m | 7 +- .../View/RoomRecommend/XPRoomRecommendView.m | 9 +- .../Main/Tabbar/View/TabbarViewController.m | 4 +- 25 files changed, 99 insertions(+), 1024 deletions(-) delete mode 100644 xplan-ios/Main/Room/View/LittleGame/Presenter/Category/NSString+RW.h delete mode 100644 xplan-ios/Main/Room/View/LittleGame/Presenter/Category/NSString+RW.m delete mode 100644 xplan-ios/Main/Room/View/LittleGame/Presenter/Category/UIColor+RW.h delete mode 100644 xplan-ios/Main/Room/View/LittleGame/Presenter/Category/UIColor+RW.m diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index ff8799b0..4a91f891 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -995,8 +995,6 @@ E8A73F8728586A6F00FD9CBC /* XPGiftWeekStarCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A73F8628586A6F00FD9CBC /* XPGiftWeekStarCollectionViewCell.m */; }; E8A86DF727BA2F1C001C21F9 /* XPRoomLittleGameContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A86DF627BA2F1C001C21F9 /* XPRoomLittleGameContainerView.m */; }; E8A86E0427BA38DB001C21F9 /* SudCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A86DF927BA38DB001C21F9 /* SudCommon.m */; }; - E8A86E0527BA38DB001C21F9 /* NSString+RW.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A86DFC27BA38DB001C21F9 /* NSString+RW.m */; }; - E8A86E0627BA38DB001C21F9 /* UIColor+RW.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A86DFE27BA38DB001C21F9 /* UIColor+RW.m */; }; E8A86E0727BA38DB001C21F9 /* NSData+RW.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A86DFF27BA38DB001C21F9 /* NSData+RW.m */; }; E8A86E0827BA38DB001C21F9 /* UIImage+RW.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A86E0127BA38DB001C21F9 /* UIImage+RW.m */; }; E8A86E0D27BA6B71001C21F9 /* SudMGP.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E8A86E0A27BA3943001C21F9 /* SudMGP.xcframework */; }; @@ -3074,13 +3072,9 @@ E8A86DF627BA2F1C001C21F9 /* XPRoomLittleGameContainerView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomLittleGameContainerView.m; sourceTree = ""; }; E8A86DF927BA38DB001C21F9 /* SudCommon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SudCommon.m; sourceTree = ""; }; E8A86DFA27BA38DB001C21F9 /* SudCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SudCommon.h; sourceTree = ""; }; - E8A86DFC27BA38DB001C21F9 /* NSString+RW.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+RW.m"; sourceTree = ""; }; E8A86DFD27BA38DB001C21F9 /* UIImage+RW.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+RW.h"; sourceTree = ""; }; - E8A86DFE27BA38DB001C21F9 /* UIColor+RW.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+RW.m"; sourceTree = ""; }; E8A86DFF27BA38DB001C21F9 /* NSData+RW.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+RW.m"; sourceTree = ""; }; - E8A86E0027BA38DB001C21F9 /* NSString+RW.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+RW.h"; sourceTree = ""; }; E8A86E0127BA38DB001C21F9 /* UIImage+RW.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+RW.m"; sourceTree = ""; }; - E8A86E0227BA38DB001C21F9 /* UIColor+RW.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+RW.h"; sourceTree = ""; }; E8A86E0327BA38DB001C21F9 /* NSData+RW.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+RW.h"; sourceTree = ""; }; E8A86E0A27BA3943001C21F9 /* SudMGP.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = SudMGP.xcframework; sourceTree = ""; }; E8A86E0C27BA3DF4001C21F9 /* SudGameConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SudGameConfig.h; sourceTree = ""; }; @@ -7654,13 +7648,9 @@ E8A86DFB27BA38DB001C21F9 /* Category */ = { isa = PBXGroup; children = ( - E8A86DFC27BA38DB001C21F9 /* NSString+RW.m */, E8A86DFD27BA38DB001C21F9 /* UIImage+RW.h */, - E8A86DFE27BA38DB001C21F9 /* UIColor+RW.m */, E8A86DFF27BA38DB001C21F9 /* NSData+RW.m */, - E8A86E0027BA38DB001C21F9 /* NSString+RW.h */, E8A86E0127BA38DB001C21F9 /* UIImage+RW.m */, - E8A86E0227BA38DB001C21F9 /* UIColor+RW.h */, E8A86E0327BA38DB001C21F9 /* NSData+RW.h */, ); path = Category; @@ -9634,7 +9624,6 @@ E8A88D3027E85EEA00CA8837 /* RoomPKInfoModel.m in Sources */, E8AB633328AE51470023B0D2 /* XPSailingPrizeView.m in Sources */, 9B2F72D328E45C5A0000E4FA /* XPRoomQuidkMessageCell.m in Sources */, - E8A86E0527BA38DB001C21F9 /* NSString+RW.m in Sources */, E83CD1982908D2FF00920A94 /* NobleRankListModel.m in Sources */, E800162C2803FE4900D6D17A /* GuildIncomeRecordModel.m in Sources */, 9BE01ACE28925F7D00B50299 /* XPMineNewUserRechargeView.m in Sources */, @@ -9910,7 +9899,6 @@ E8C6FFCB27548120004DC9F0 /* XPHomePartyViewController.m in Sources */, E8680718271967B00024F48F /* MicroView.m in Sources */, E896EF942771AAC100AD2CC1 /* XPMineFansPresenter.m in Sources */, - E8A86E0627BA38DB001C21F9 /* UIColor+RW.m in Sources */, E8B825CD26EA18C8009E8E9F /* ThemeColor.m in Sources */, E8751E5F28A62A970056EF44 /* XPSailingPresenter.m in Sources */, E8DAC5AC2858305A00012CFD /* XPRoomMessageBubbleView.m in Sources */, diff --git a/xplan-ios/Base/MVP/Api/Api.m b/xplan-ios/Base/MVP/Api/Api.m index 9032bced..ff2aa180 100644 --- a/xplan-ios/Base/MVP/Api/Api.m +++ b/xplan-ios/Base/MVP/Api/Api.m @@ -19,9 +19,16 @@ // NSLog 一下 __FUNCTION__ 就知道为什么这么截取了。 NSRange blankRange = [fn rangeOfString:@":"]; NSUInteger start = blankRange.location + 1; - NSUInteger length = fn.length - start - 2; + NSUInteger length; + if ((start + 2) < fn.length) { + length = fn.length - start - 2; + } else if ((start + 1) < fn.length) { + length = fn.length -start - 1; + } else { + length = fn.length -start; + } + NSString *fromatParamKeys = [fn substringWithRange:NSMakeRange(start, length)]; - // 构造请求的 NSMutableDictionary *params 。 NSMutableDictionary *params = [NSMutableDictionary dictionary]; diff --git a/xplan-ios/Main/Home/View/XPHomeLivesViewController.m b/xplan-ios/Main/Home/View/XPHomeLivesViewController.m index f26d65df..a0f0ac7a 100644 --- a/xplan-ios/Main/Home/View/XPHomeLivesViewController.m +++ b/xplan-ios/Main/Home/View/XPHomeLivesViewController.m @@ -20,6 +20,7 @@ #import "StatisticsServiceHelper.h" #import "XPWeakTimer.h" #import "NSMutableDictionary+Saft.h" +#import "NSArray+Safe.h" ///Model #import "HomeLiveTagModel.h" #import "HomeLiveLookRecordModel.h" @@ -204,13 +205,13 @@ - (id)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index { XPHomeLivePageViewController * homeVC = [[XPHomeLivePageViewController alloc] init]; - HomeLiveTagModel *tag = self.tagList[index]; + HomeLiveTagModel *tag = [self.tagList safeObjectAtIndex1:index]; homeVC.tabId = tag.tid; return homeVC; } - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { - HomeLiveTagModel *tag = self.tagList[index]; + HomeLiveTagModel *tag = [self.tagList safeObjectAtIndex1:index]; NSMutableDictionary * dic = [NSMutableDictionary dictionary]; [dic safeSetObject: tag.sortName forKey:@"geboTagName"]; [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventGebo_tab_click eventAttributes:dic]; diff --git a/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.m b/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.m index a36abdeb..de656b9c 100644 --- a/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.m +++ b/xplan-ios/Main/Home/View/XPRoomSearchRecordViewController.m @@ -195,14 +195,14 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; return cell; } else { XPHomeAttentionCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPHomeAttentionCollectionViewCell class]) forIndexPath:indexPath]; - cell.recordRoom = self.inRoomList[indexPath.row]; + cell.recordRoom = [self.inRoomList safeObjectAtIndex1:indexPath.row]; return cell; } } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { if (collectionView == self.searchCollectionView) { - NSString *str = self.searchList[indexPath.row]; + NSString *str = [self.searchList safeObjectAtIndex1:indexPath.row]; if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomSearchRecordViewControllerSearchWithWord:)]) { [self.delegate xPRoomSearchRecordViewControllerSearchWithWord:str]; } @@ -213,7 +213,7 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey"; [self.delegate xPRoomSearchRecordViewControllerEveryoneSearch:model.word sid:model.sid]; } } else { - XPMineFootPrintModel *resultModel = self.inRoomList[indexPath.row]; + XPMineFootPrintModel *resultModel = [self.inRoomList safeObjectAtIndex1:indexPath.row]; [self dismissViewControllerAnimated:YES completion:nil]; if (resultModel.valid) { [XPRoomViewController openRoom:resultModel.roomUid viewController:self.presentingViewController]; diff --git a/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m b/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m index 7f19edc6..a4e41565 100644 --- a/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m +++ b/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m @@ -209,7 +209,7 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; if (self.openType == SessionListOpenTypeRoom) { - NIMRecentSession *recentSession = self.recentSessions[indexPath.row]; + NIMRecentSession *recentSession = [self.recentSessions safeObjectAtIndex1:indexPath.row]; SessionViewController * sessionVC =[[SessionViewController alloc] initWithSession:recentSession.session]; sessionVC.openType = self.openType; CATransition *transition = [CATransition animation]; @@ -221,7 +221,7 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; [self.mainController.view addSubview:sessionVC.view]; [self.mainController addChildViewController:sessionVC]; } else { - NIMRecentSession *recentSession = self.recentSessions[indexPath.row]; + NIMRecentSession *recentSession = [self.recentSessions safeObjectAtIndex1:indexPath.row]; SessionViewController *vc = [[SessionViewController alloc] initWithSession:recentSession.session]; vc.openType = self.openType; [self.navigationController pushViewController:vc animated:YES]; @@ -259,7 +259,7 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; if (!cell) { cell = [[SessionListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]; } - NIMRecentSession *recent = self.recentSessions[indexPath.row]; + NIMRecentSession *recent = [self.recentSessions safeObjectAtIndex1:indexPath.row]; [cell renderWithSession:recent]; return cell; } @@ -313,8 +313,9 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; totalUnreadCount:(NSInteger)totalUnreadCount { // 清理本地数据 NSUInteger index = [self.recentSessions indexOfObject:recentSession]; - [self.recentSessions removeObjectAtIndex:index]; - + if (index < self.recentSessions.count) { + [self.recentSessions removeObjectAtIndex:index]; + } // 如果删除本地会话后就不允许漫游当前会话,则需要进行一次删除服务器会话的操作 BOOL deleteRemote = NO; if (deleteRemote) { diff --git a/xplan-ios/Main/Mine/View/Noble/View/XPNobleRankViewController.m b/xplan-ios/Main/Mine/View/Noble/View/XPNobleRankViewController.m index bdaf0e42..5090d3b7 100644 --- a/xplan-ios/Main/Mine/View/Noble/View/XPNobleRankViewController.m +++ b/xplan-ios/Main/Mine/View/Noble/View/XPNobleRankViewController.m @@ -15,6 +15,7 @@ #import "XPNobleRankTableViewCell.h" #import "XPNobleMyInfoView.h" #import "XPNobleRankUpdateView.h" +#import "NSArray+Safe.h" ///P #import "XPNobleCenterPresenter.h" #import "XPNobleCenterProtocol.h" @@ -139,7 +140,7 @@ if (cell == nil) { cell = [[XPNobleRankTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPNobleRankTableViewCell class])]; } - NObleRankUserModel * userInfo = self.datasource[indexPath.row]; + NObleRankUserModel * userInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; cell.userInfo = userInfo; return cell; } diff --git a/xplan-ios/Main/Mine/View/Recharge/XPMineRechargeViewController.m b/xplan-ios/Main/Mine/View/Recharge/XPMineRechargeViewController.m index e646a036..f790cbd5 100644 --- a/xplan-ios/Main/Mine/View/Recharge/XPMineRechargeViewController.m +++ b/xplan-ios/Main/Mine/View/Recharge/XPMineRechargeViewController.m @@ -17,6 +17,7 @@ #import "RechargeStorage.h" #import "AccountInfoStorage.h" #import "NSObject+MJExtension.h" +#import "NSArray+Safe.h" ///Model #import "RechargeListModel.h" ///View @@ -159,7 +160,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { XPMineRechargeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineRechargeTableViewCell class]) forIndexPath:indexPath]; - cell.listModel = self.datasource[indexPath.row]; + cell.listModel = [self.datasource safeObjectAtIndex1:indexPath.row]; cell.delegate = self; return cell; } diff --git a/xplan-ios/Main/Mine/View/SkillCard/View/SubViews/XPSkillCardSelectPropView.m b/xplan-ios/Main/Mine/View/SkillCard/View/SubViews/XPSkillCardSelectPropView.m index 07804d08..d561468d 100644 --- a/xplan-ios/Main/Mine/View/SkillCard/View/SubViews/XPSkillCardSelectPropView.m +++ b/xplan-ios/Main/Mine/View/SkillCard/View/SubViews/XPSkillCardSelectPropView.m @@ -99,7 +99,9 @@ break; } } - [self.selectArray removeObjectAtIndex:index]; + if (index < self.selectArray.count) { + [self.selectArray removeObjectAtIndex:index]; + } } else { XPSkillCardSourcePropDetailModel *propItem = [[XPSkillCardSourcePropDetailModel alloc] init]; propItem.parentId = self.propModel.propId; @@ -128,8 +130,13 @@ } } if (index > -1) { - [self.selectArray removeObjectAtIndex:index]; - [self.selectPropNameArray removeObjectAtIndex:index]; + if (index < self.selectArray.count) { + [self.selectArray removeObjectAtIndex:index]; + } + + if (index < self.selectPropNameArray.count) { + [self.selectPropNameArray removeObjectAtIndex:index]; + } } } } diff --git a/xplan-ios/Main/Mine/View/XPMineFootPrintViewController.m b/xplan-ios/Main/Mine/View/XPMineFootPrintViewController.m index 87af7556..1f0ed165 100644 --- a/xplan-ios/Main/Mine/View/XPMineFootPrintViewController.m +++ b/xplan-ios/Main/Mine/View/XPMineFootPrintViewController.m @@ -12,6 +12,7 @@ ///Tool #import "ThemeColor.h" #import "XPMacro.h" +#import "NSArray+Safe.h" ///Model #import "XPMineFootPrintModel.h" ///View @@ -191,7 +192,7 @@ } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - XPMineFootPrintModel *model = self.datasource[indexPath.row]; + XPMineFootPrintModel *model = [self.datasource safeObjectAtIndex1:indexPath.row]; if (model.roomUid.integerValue > 0) { [XPRoomViewController openRoom:model.roomUid viewController:self]; } diff --git a/xplan-ios/Main/ModuleKit/FaceView/View/XPRoomFaceViewController.m b/xplan-ios/Main/ModuleKit/FaceView/View/XPRoomFaceViewController.m index dc00c3cb..987bff12 100644 --- a/xplan-ios/Main/ModuleKit/FaceView/View/XPRoomFaceViewController.m +++ b/xplan-ios/Main/ModuleKit/FaceView/View/XPRoomFaceViewController.m @@ -226,7 +226,9 @@ int t = arc4random()%startArray.count; resultArray[i]=startArray[t]; startArray[t]=[startArray lastObject]; //为更好的乱序,故交换下位置 - [startArray removeLastObject]; + if (startArray.count > 0) { + [startArray removeLastObject]; + } } return resultArray; } diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftHeadTypeView.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftHeadTypeView.m index 88225438..b53bf875 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftHeadTypeView.m +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftHeadTypeView.m @@ -11,6 +11,7 @@ #import /// #import "ThemeColor.h" +#import "NSArray+Safe.h" static NSString *kHideGiftViewInteractDot = @"kHideGiftViewInteractDot";//是否隐藏互动红点 @@ -108,7 +109,7 @@ static NSString *kHideGiftViewInteractDot = @"kHideGiftViewInteractDot";//是否 #pragma mark - SDCycleScrollViewDelegate - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index { if (self.titleArray.count > index) { - NSString *str = self.titleArray[index]; + NSString *str = [self.titleArray safeObjectAtIndex1:index]; if([str isEqualToString:@"首充有礼"]) { if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftHeadTypeViewDidClickFirstRecharge:)]) { [self.delegate xPGiftHeadTypeViewDidClickFirstRecharge:self]; diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGraffitiGiftView.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGraffitiGiftView.m index c880af50..cd848e22 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGraffitiGiftView.m +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGraffitiGiftView.m @@ -225,7 +225,9 @@ if (array.count) { [array makeObjectsPerformSelector:@selector(removeFromSuperview)]; } - [self.indexArray removeLastObject]; + if (self.indexArray.count > 0) { + [self.indexArray removeLastObject]; + } [self cratePriceAttribute]; if (self.delegate && [self.delegate respondsToSelector:@selector(xPGraffitiGiftView:didDrawCompletion:)]) { [self.delegate xPGraffitiGiftView:self didDrawCompletion:self.pointArray]; diff --git a/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m index 558cc0ee..cb4f1eb7 100644 --- a/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m +++ b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m @@ -249,18 +249,25 @@ if (firstRechargeActivity && [self.activityList containsObject:firstRechargeActivity]) { NSInteger index = [self.activityList indexOfObject:firstRechargeActivity]; - [self.imageUrlList removeObjectAtIndex:index]; + if (index < self.imageUrlList.count) { + [self.imageUrlList removeObjectAtIndex:index]; + } + [self.activityList removeObject:firstRechargeActivity]; } if (candyActivity && [self.activityList containsObject:candyActivity]) { NSInteger index = [self.activityList indexOfObject:candyActivity]; - [self.imageUrlList removeObjectAtIndex:index]; + if (index < self.imageUrlList.count) { + [self.imageUrlList removeObjectAtIndex:index]; + } [self.activityList removeObject:candyActivity]; } if (sailingActivity && [self.activityList containsObject:sailingActivity]) { NSInteger index = [self.activityList indexOfObject:sailingActivity]; - [self.imageUrlList removeObjectAtIndex:index]; + if (index < self.imageUrlList.count) { + [self.imageUrlList removeObjectAtIndex:index]; + } [self.activityList removeObject:sailingActivity]; } } diff --git a/xplan-ios/Main/Room/View/AnchorView/FansTeam/View/XPAnchorFansTaskViewController.m b/xplan-ios/Main/Room/View/AnchorView/FansTeam/View/XPAnchorFansTaskViewController.m index e96595bb..990e72ba 100644 --- a/xplan-ios/Main/Room/View/AnchorView/FansTeam/View/XPAnchorFansTaskViewController.m +++ b/xplan-ios/Main/Room/View/AnchorView/FansTeam/View/XPAnchorFansTaskViewController.m @@ -19,6 +19,7 @@ #import "TTPopup.h" #import "XPHtmlUrl.h" #import "UIButton+EnlargeTouchArea.h" +#import "NSArray+Safe.h" ///View #import "XPAnchorFansTaskTableViewCell.h" #import "XPRoomHalfWebView.h" @@ -269,7 +270,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { XPAnchorFansTaskTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPAnchorFansTaskTableViewCell class])]; - XPAnchorFansTaskDetailModel *model = self.model.taskVos[indexPath.row]; + XPAnchorFansTaskDetailModel *model = [self.model.taskVos safeObjectAtIndex1:indexPath.row]; cell.model = model; return cell; diff --git a/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m b/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m index 4d14b467..e2702604 100644 --- a/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m +++ b/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m @@ -668,7 +668,9 @@ @kStrongify(self); if (finished) { [candyTreeView removeFromSuperview]; - [self.candyTreegiftQueue removeObjectAtIndex:0]; + if (self.candyTreegiftQueue.count > 0) { + [self.candyTreegiftQueue removeObjectAtIndex:0]; + } if (self.candyTreegiftQueue.count > 0) { [self createCandyTreeBannerAnimation:self.candyTreegiftQueue.firstObject]; } @@ -713,7 +715,9 @@ @kStrongify(self); if (finished) { [sailingView removeFromSuperview]; - [self.sailingQueue removeObjectAtIndex:0]; + if (self.sailingQueue.count > 0) { + [self.sailingQueue removeObjectAtIndex:0]; + } if (self.sailingQueue.count > 0) { [self createSailingBannerAnimation:self.sailingQueue.firstObject]; } @@ -756,7 +760,9 @@ @kStrongify(self); if (finished) { [nobleLevelUpView removeFromSuperview]; - [self.nobleLevelUpQueue removeObjectAtIndex:0]; + if (self.nobleLevelUpQueue > 0) { + [self.nobleLevelUpQueue removeObjectAtIndex:0]; + } if (self.nobleLevelUpQueue.count > 0) { [self createNobleLevelUpBannerAnimation:self.nobleLevelUpQueue.firstObject]; } @@ -800,7 +806,10 @@ @kStrongify(self); if (finished) { [compoundGiftView removeFromSuperview]; - [self.compoundGiftQueue removeObjectAtIndex:0]; + if (self.compoundGiftQueue.count > 0) { + [self.compoundGiftQueue removeObjectAtIndex:0]; + } + if (self.compoundGiftQueue.count > 0) { [self createGiftCompoundBannerAnimation:self.compoundGiftQueue.firstObject]; } @@ -1143,7 +1152,10 @@ @kStrongify(self); if (finished) { [view removeFromSuperview]; - [self.giftBroadcastQueue removeObjectAtIndex:0]; + if (self.giftBroadcastQueue.count > 0) { + [self.giftBroadcastQueue removeObjectAtIndex:0]; + } + if (self.giftBroadcastQueue.count > 0) { [self createGiftBroadcastViewAnimation:self.giftBroadcastQueue.firstObject]; } @@ -1568,7 +1580,9 @@ } else if(player == self.enterEffectView) { self.enterEffectView.hidden = YES; [self.enterEffectView removeFromSuperview]; - [self.enterEffectQueue removeObjectAtIndex:0]; + if (self.enterEffectQueue.count > 0) { + [self.enterEffectQueue removeObjectAtIndex:0]; + } if (self.enterEffectQueue.count > 0) { NSString * title = [self.enterEffectQueue.firstObject objectForKey:@"title"]; NSInteger experLevelSeq = [(NSString *)[self.enterEffectQueue.firstObject objectForKey:@"experLevelSeq"] integerValue]; @@ -1655,7 +1669,9 @@ if (container == self.carVapEffectView) { [self.carVapEffectView removeFromSuperview]; self.carVapEffectView = nil; - [self.carEffectQueue removeObjectAtIndex:0]; + if (self.carEffectQueue.count > 0) { + [self.carEffectQueue removeObjectAtIndex:0]; + } if (self.carEffectQueue.count > 0) { [self playCarEffect:self.carEffectQueue.firstObject]; } diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m index 8f655235..c4ce7e18 100644 --- a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m @@ -1442,8 +1442,10 @@ @strongify(self); if (self.trumpetQueue.count) { dispatch_sync(dispatch_get_main_queue(), ^{ - [self createTrumpetAnimation:self.trumpetQueue.firstObject]; - [self.trumpetQueue removeObjectAtIndex:0]; + [self createTrumpetAnimation:[self.trumpetQueue safeObjectAtIndex1:0]]; + if (self.trumpetQueue.count > 0) { + [self.trumpetQueue removeObjectAtIndex:0]; + } }); } else { dispatch_sync(dispatch_get_main_queue(), ^{ diff --git a/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeMoreView.m b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeMoreView.m index ebc2286a..a2ab225f 100644 --- a/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeMoreView.m +++ b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeMoreView.m @@ -93,7 +93,7 @@ NSString * const kCandyTreeHideMessage = @"kCandyTreeHideMessage"; return cell; } XPCandyTreeMoreRuleCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPCandyTreeMoreRuleCell class])]; - cell.title = self.datasource[indexPath.row]; + cell.title = [self.datasource safeObjectAtIndex1:indexPath.row]; cell.delegate = self; NSString *showSwitch = [[NSUserDefaults standardUserDefaults] objectForKey:kCandyTreeHideMessage]; cell.isShow = !showSwitch.length; diff --git a/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/NSString+RW.h b/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/NSString+RW.h deleted file mode 100644 index 7cc66917..00000000 --- a/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/NSString+RW.h +++ /dev/null @@ -1,270 +0,0 @@ -/** - * Copyright © Sud.Tech - * https://sud.tech - */ - -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface NSString (RW) -#pragma mark - Hash -///============================================================================= -/// @name Hash -///============================================================================= - -/** - Returns a lowercase NSString for md5 hash. - */ -- (nullable NSString *)md5String; - -/** - Returns a lowercase NSString for sha256 hash. - */ -- (nullable NSString *)sha256String; - -/** - Returns a lowercase NSString for sha1 hash. - */ -- (nullable NSString *)sha1String; - -/** - 对self进行AES加密(返回加密后的Base64字符) - - @param key A key length of 16, 24 or 32 (128, 192 or 256bits). - @param iv An initialization vector length of 16(128bits). - Pass nil when you don't want to use iv. - - @return An NSString encrypted, or nil if an error occurs. - */ -- (nullable NSString *)aesEncryptWithKey:(NSString *)key iv:(nullable NSString *)iv; - -/** - 对self进行AES解密(self为Base64字符) - - @param key A key length of 16, 24 or 32 (128, 192 or 256bits). - @param iv An initialization vector length of 16(128bits). - Pass nil when you don't want to use iv. - - @return An NSString encrypted, or nil if an error occurs. - */ -- (nullable NSString *)aesDecryptWithkey:(NSString *)key iv:(nullable NSString *)iv; - -#pragma mark - Encode and decode -///============================================================================= -/// @name Encode and decode -///============================================================================= - -/** - Returns an NSString for base64 encoded. - */ -- (nullable NSString *)base64EncodedString; - -/** - Returns an NSString from base64 encoded string. - @param base64EncodedString string. - */ -+ (nullable NSString *)stringWithBase64EncodedString:(NSString *)base64EncodedString; - -/** - URL encode a string in utf-8. - @return the encoded string. - */ -- (NSString *)stringByURLEncode; - -/** - URL decode a string in utf-8. - @return the decoded string. - */ -- (NSString *)stringByURLDecode; - -#pragma mark - Drawing -///============================================================================= -/// @name Drawing -///============================================================================= - -/** - * 获取文本标签size - * 截断方式为NSLineBreakByWordWrapping, 对齐方式默认为NSTextAlignmentLeft - * @param font 字体 - * @param size 限定范围 - * - * @return 返回文本标签实际size - */ -- (CGSize)textSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size; - -/** - * 获取文本标签size - * 对齐方式为NSTextAlignmentLeft - * @param font 字体 - * @param size 限定范围 - * @param lineBreakMode 截断方式 - * - * @return 返回文本标签实际size - */ -- (CGSize)textSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size withLineBreakingMode:(NSLineBreakMode)lineBreakMode; - -/** - * 获取文本标签size - * - * @param font 字体 - * @param size 限定范围 - * @param lineBreakingMode 截断方式 - * @param textAlignment 文字对齐类型 - * - * @return 返回文本标签实际size - */ -- (CGSize)textSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size withLineBreakingMode:(NSLineBreakMode)lineBreakingMode withTextAlignment:(NSTextAlignment)textAlignment; - - -/** - Returns the width of the string if it were to be rendered with the specified - font on a single line. - - @param font The font to use for computing the string width. - - @return The width of the resulting string's bounding box. These values may be - rounded up to the nearest whole number. - */ -- (CGFloat)widthForFont:(UIFont *)font; - -/** - Returns the height of the string if it were rendered with the specified constraints. - - @param font The font to use for computing the string size. - - @param width The maximum acceptable width for the string. This value is used - to calculate where line breaks and wrapping would occur. - - @return The height of the resulting string's bounding box. These values - may be rounded up to the nearest whole number. - */ -- (CGFloat)heightForFont:(UIFont *)font width:(CGFloat)width; - - -#pragma mark - Utilities -///============================================================================= -/// @name Utilities -///============================================================================= - -/** - Returns a new UUID NSString - e.g. "D1178E50-2A4D-4F1F-9BD3-F6AAB00E06B1" - */ -+ (NSString *)stringWithUUID; - -/** - Trim blank characters (space and newline) in head and tail. - @return the trimmed string. - */ -- (NSString *)stringByTrim; - -/** - nil, @"", @" ", @"\n" will Returns NO; otherwise Returns YES. - */ -- (BOOL)isNotBlank; - -/** - Returns YES if the target string is contained within the receiver. - @param string A string to test the the receiver. - - @discussion Apple has implemented this method in iOS8. - */ -- (BOOL)containsString:(NSString *)string; - -/** - Returns YES if the target string is contained within the receiver. - @param string A string to test the the receiver. - @param mask NSStringCompareOptions - - */ -- (BOOL)containsString:(NSString *)string options:(NSStringCompareOptions)mask; - -/** - Returns YES if the target string is hasPrefix within the receiver. - default NSCaseInsensitiveSearch - @param string A string to test the the receiver. - - */ -- (BOOL)hasInsensitivePrefix:(NSString *)string; - -/** - Returns YES if the target string is hasPrefix within the receiver. - @param string A string to test the the receiver. - @param mask NSStringCompareOptions - - */ -- (BOOL)hasPrefix:(NSString *)string options:(NSStringCompareOptions)mask; - -/** - Returns YES if the target CharacterSet is contained within the receiver. - @param set A character set to test the the receiver. - */ -- (BOOL)containsCharacterSet:(NSCharacterSet *)set; - -/** - Returns an NSData using UTF-8 encoding. - */ -- (NSData *)dataValue; - -/** - Returns NSMakeRange(0, self.length). - */ -- (NSRange)rangeOfAll; - -/** - Returns an NSDictionary/NSArray which is decoded from receiver. - Returns nil if an error occurs. - - e.g. NSString: @"{"name":"a","count":2}" => NSDictionary: @[@"name":@"a",@"count":@2] - */ -- (id)jsonValueDecoded; - -+ (NSString *) jsonStringWithDictionary:(NSDictionary *)dictionary; - - -//密码需8-16位,至少包含字母、数字、符号2种组合 -+(BOOL)checkIsHaveNumAndLetter:(NSString*)sting; - -/** - 中国电信号段为:133、149、153、173、177。还有180、181、189、199。 - - 中国联通号段:130、131、132、145、155、156、166、171、175、176、185、186、166。 - - 中国移动号段:134(0-8)、135、136、137、138、139、147、150、151、152、157、158、159、172、178、182、183、184、187、188、198 - */ -///判断是否为手机号 -- (BOOL)isPhoneNum; - -///判断是否包含中文 -- (BOOL)isContainsChinese; - -///包含特殊字符Special characters -- (BOOL)isContainsSpecialCharacters; - -///是否是纯数字 -+ (BOOL)isAllNumText:(NSString *)str; - -///纯中文字符串 -+ (BOOL)isChineseCharacter:(NSString*)source; - -///纯英文字符串 -+ (BOOL)isEnglishCharacter:(NSString*)source; - -///纯特殊字符 -+ (BOOL)isAllCharacterString:(NSString *)string; - -/// 包含emoji -+ (BOOL)stringContainsEmoji:(NSString *)string; - - -///去除字符串两端的空格和换行符 -- (NSString *)RW_stringByTrimmingCharacters; - -/// 汉字转成拼音的方法 -+ (NSString *)chineseTransformToPinyin:(NSString *)chinese; - -@end - -NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/NSString+RW.m b/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/NSString+RW.m deleted file mode 100644 index 583fcc93..00000000 --- a/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/NSString+RW.m +++ /dev/null @@ -1,522 +0,0 @@ -/** - * Copyright © Sud.Tech - * https://sud.tech - */ - -#import "NSString+RW.h" -#import "NSData+RW.h" -#import "NSArray+Safe.h" - -@implementation NSString (RW) - - -(NSString *)md5String { - return [[self dataUsingEncoding:NSUTF8StringEncoding] md5String]; -} - -- (NSString *)sha256String { - return [[self dataUsingEncoding:NSUTF8StringEncoding] sha256String]; -} - -- (NSString *)sha1String { - return [[self dataUsingEncoding:NSUTF8StringEncoding] sha1String]; -} - -- (nullable NSString *)aesEncryptWithKey:(NSString *)key iv:(nullable NSString *)iv { - NSData * data = [self dataUsingEncoding:NSUTF8StringEncoding]; - data = [data aesEncryptWithKey:[key dataUsingEncoding:NSUTF8StringEncoding] - iv:[iv dataUsingEncoding:NSUTF8StringEncoding]]; - //一般使用Base64, 使用UTF-8,一般会返回nil - return [data base64EncodedString]; -} - -- (nullable NSString *)aesDecryptWithkey:(NSString *)key iv:(nullable NSString *)iv { - NSData * data = [NSData dataWithBase64EncodedString:self]; - data = [data aesDecryptWithkey:[key dataUsingEncoding:NSUTF8StringEncoding] - iv:[iv dataUsingEncoding:NSUTF8StringEncoding]]; - NSString * result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - return result; -} - -- (NSString *)base64EncodedString { - return [[self dataUsingEncoding:NSUTF8StringEncoding] base64EncodedString]; -} - -+ (NSString *)stringWithBase64EncodedString:(NSString *)base64EncodedString { - NSData *data = [NSData dataWithBase64EncodedString:base64EncodedString]; - return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; -} - -- (NSString *)stringByURLEncode { - if ([self respondsToSelector:@selector(stringByAddingPercentEncodingWithAllowedCharacters:)]) { - - static NSString * const kAFCharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4 - static NSString * const kAFCharactersSubDelimitersToEncode = @"!$&'()*+,;="; - - NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy]; - [allowedCharacterSet removeCharactersInString:[kAFCharactersGeneralDelimitersToEncode stringByAppendingString:kAFCharactersSubDelimitersToEncode]]; - static NSUInteger const batchSize = 50; - - NSUInteger index = 0; - NSMutableString *escaped = @"".mutableCopy; - - while (index < self.length) { - NSUInteger length = MIN(self.length - index, batchSize); - NSRange range = NSMakeRange(index, length); - // To avoid breaking up character sequences such as 👴🏻👮🏽 - range = [self rangeOfComposedCharacterSequencesForRange:range]; - NSString *substring = [self substringWithRange:range]; - NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; - [escaped appendString:encoded]; - - index += range.length; - } - return escaped; - } else { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - CFStringEncoding cfEncoding = CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding); - NSString *encoded = (__bridge_transfer NSString *) - CFURLCreateStringByAddingPercentEscapes( - kCFAllocatorDefault, - (__bridge CFStringRef)self, - NULL, - CFSTR("!#$&'()*+,/:;=?@[]"), - cfEncoding); - return encoded; -#pragma clang diagnostic pop - } -} - -- (NSString *)stringByURLDecode { - if ([self respondsToSelector:@selector(stringByRemovingPercentEncoding)]) { - return [self stringByRemovingPercentEncoding]; - } else { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - CFStringEncoding en = CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding); - NSString *decoded = [self stringByReplacingOccurrencesOfString:@"+" - withString:@" "]; - decoded = (__bridge_transfer NSString *) - CFURLCreateStringByReplacingPercentEscapesUsingEncoding( - NULL, - (__bridge CFStringRef)decoded, - CFSTR(""), - en); - return decoded; -#pragma clang diagnostic pop - } -} - -- (CGSize)textSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size -{ - return [self textSizeWithFont:font constrainedToSize:size withLineBreakingMode:NSLineBreakByWordWrapping]; -} - -- (CGSize)textSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size withLineBreakingMode:(NSLineBreakMode)lineBreakMode { - return [self textSizeWithFont:font constrainedToSize:size withLineBreakingMode:NSLineBreakByWordWrapping withTextAlignment:NSTextAlignmentLeft]; -} - -- (CGSize)textSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size withLineBreakingMode:(NSLineBreakMode)lineBreakingMode withTextAlignment:(NSTextAlignment)textAlignment -{ - CGSize textSize; - - NSMutableParagraphStyle *style = nil; - style = [[NSMutableParagraphStyle alloc] init]; - style.lineBreakMode = lineBreakingMode; - style.alignment = textAlignment; - - NSMutableDictionary *attributes = [NSMutableDictionary new]; - attributes[NSFontAttributeName] = font; - [attributes setValue:style forKey:NSParagraphStyleAttributeName]; - - if (CGSizeEqualToSize(size, CGSizeZero)) { - textSize = [self sizeWithAttributes:attributes]; - } - else { - //NSStringDrawingTruncatesLastVisibleLine如果文本内容超出指定的矩形限制,文本将被截去并在最后一个字符后加上省略号。 如果指定了NSStringDrawingUsesLineFragmentOrigin选项,则该选项被忽略 NSStringDrawingUsesFontLeading计算行高时使用行间距。(译者注:字体大小+行间距=行高) - NSStringDrawingOptions option = NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading; - CGRect rect = [self boundingRectWithSize:size - options:option - attributes:attributes - context:nil]; - textSize = rect.size; - } - - return textSize; -} - -- (CGFloat)widthForFont:(UIFont *)font { - CGSize size = [self textSizeWithFont:font constrainedToSize:CGSizeMake(HUGE, HUGE)]; - return size.width; -} - - -- (CGFloat)heightForFont:(UIFont *)font width:(CGFloat)width { - CGSize size = [self textSizeWithFont:font constrainedToSize:CGSizeMake(width, HUGE)]; - return size.height; -} - - -+ (NSString *)stringWithUUID { - CFUUIDRef uuid = CFUUIDCreate(NULL); - CFStringRef string = CFUUIDCreateString(NULL, uuid); - CFRelease(uuid); - return (__bridge_transfer NSString *)string; -} - -- (NSString *)stringByTrim { - NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet]; - return [self stringByTrimmingCharactersInSet:set]; -} - -- (BOOL)isNotBlank { - NSCharacterSet *blank = [NSCharacterSet whitespaceAndNewlineCharacterSet]; - for (NSInteger i = 0; i < self.length; ++i) { - unichar c = [self characterAtIndex:i]; - if (![blank characterIsMember:c]) { - return YES; - } - } - return NO; -} - -- (BOOL)containsString:(NSString *)string { - if (string == nil) return NO; - return [self rangeOfString:string].location != NSNotFound; -} - -- (BOOL)containsString:(NSString *)string options:(NSStringCompareOptions)mask{ - if (string == nil) return NO; - return [self rangeOfString:string options:mask].location != NSNotFound; -} - -- (BOOL)hasInsensitivePrefix:(NSString *)string{ - if (string == nil) return NO; - NSString *commonStr = [self commonPrefixWithString:string options:NSCaseInsensitiveSearch]; - if ([commonStr caseInsensitiveCompare:string] == NSOrderedSame) { - return YES; - }else{ - return NO; - } -} - -- (BOOL)hasPrefix:(NSString *)string options:(NSStringCompareOptions)mask{ - if (string == nil) return NO; - NSString *commonStr = [self commonPrefixWithString:string options:mask]; - if ([commonStr caseInsensitiveCompare:string] == NSOrderedSame) { - return YES; - }else{ - return NO; - } -} - -- (BOOL)containsCharacterSet:(NSCharacterSet *)set { - if (set == nil) return NO; - return [self rangeOfCharacterFromSet:set].location != NSNotFound; -} - -- (NSData *)dataValue { - return [self dataUsingEncoding:NSUTF8StringEncoding]; -} - -- (NSRange)rangeOfAll { - return NSMakeRange(0, self.length); -} - -- (id)jsonValueDecoded { - return [[self dataValue] jsonValueDecoded]; -} - - --(NSString*)coverBodyWithLength:(NSInteger)length -{ - NSMutableString* body = [NSMutableString new]; - for(int i=0;i?,.\\/]) 表示含英文的特殊字符,里面的符合可以自动补充或删除 -// -// 5、[^\\u4e00-\\u9fa5] 表示不允许有中文 ;表示允许有中文的,即:[\\u4e00-\\u9fa5] -// -// 6、{6,12} 表示长度要求,6~12位 -// 表示的是不含中文的特殊字符,以及空格与回车,里面的符合可以自动补充或删除; -// NSString *regex = @"^(?!.*[!·(){}【】“”:;,》¥、。‘’——\\s-……%\\n])(?=.*[a-zA-Z])(?=.*\\d)(?=.*[~!@#$%^&*()_+`\\-={}:\";'<>?,.\\/])[^\\u4e00-\\u9fa5]{8,16}$"; - - -// -// //数字条件 -// NSRegularExpression *tNumRegularExpression = [NSRegularExpression regularExpressionWithPattern:@"[0-9]" options:NSRegularExpressionCaseInsensitive error:nil]; -// -// //符合数字条件的有几个字节 -// NSUInteger tNumMatchCount = [tNumRegularExpression numberOfMatchesInString:sting -// options:NSMatchingReportProgress -// range:NSMakeRange(0, sting.length)]; -// //英文字条件 -// NSRegularExpression *tLetterRegularExpression = [NSRegularExpression regularExpressionWithPattern:@"[A-Za-z]" options:NSRegularExpressionCaseInsensitive error:nil]; -// -// //英文特殊字符条件 -// NSRegularExpression *specialRegularExpression = [NSRegularExpression regularExpressionWithPattern:@"[~!@#$%^&*()_+`\\-={}[]:\";'<>?,.\\/!·(){}【】“”:;,》¥、。‘’——\\s-……%\\n]" options:NSRegularExpressionCaseInsensitive error:nil]; -// -// //符合英文字条件的有几个字节 -// NSUInteger tLetterMatchCount = [tLetterRegularExpression numberOfMatchesInString:sting options:NSMatchingReportProgress range:NSMakeRange(0, sting.length)]; -// if (tNumMatchCount == sting.length) { //全部符合数字,表示沒有英文 -// return 1; -// -// } else if (tLetterMatchCount == sting.length) { //全部符合英文,表示沒有数字 -// return 2; -// -// } else if (tNumMatchCount + tLetterMatchCount == sting.length) { //符合英文和符合数字条件的相加等于密码长度 -// return 3; -// -// }else { //可能包含标点符号的情況,或是包含非英文的文字 -// return 4; -// } -} - - -- (BOOL)isPhoneNum -{ - NSString *MOBILE = @"^1(3[0-9]|4[579]|5[0-35-9]|6[6]|7[0-35-9]|8[0-9]|9[89])\\d{8}$"; - NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE]; - return [regextestmobile evaluateWithObject:self]; -} - --(BOOL)isContainsChinese{ - - for(int i=0; i< [self length];i++) - { - int a = [self characterAtIndex:i]; - if( a > 0x4E00 && a < 0x9FFF) - { - return YES; - } - } - return NO; -} - -- (BOOL)isContainsSpecialCharacters{ - - NSString *str =@"^[A-Za-z0-9\\u4e00-\u9fa5]+$"; - NSPredicate* emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", str]; - if (![emailTest evaluateWithObject:self]) { - return YES; - } - return NO; -} - -//是否是纯数字 -+ (BOOL)isAllNumText:(NSString *)str{ - - NSString *regex =@"[0-9]*"; - - NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex]; - - if ([pred evaluateWithObject:str]) { - - return YES; - - } - - return NO; - -} - -+ (BOOL)isChineseCharacter:(NSString*)source { - - NSString *regex = @"^[\\u4E00-\\u9FEA]+$"; - - return ([source rangeOfString:regex options:NSRegularExpressionSearch].length>0); - -} - -+ (BOOL)isEnglishCharacter:(NSString*)source { - - NSString *upperRegex = @"^[\\u0041-\\u005A]+$"; - - NSString *lowerRegex = @"^[\\u0061-\\u007A]+$"; - - BOOL isEnglish = (([source rangeOfString:upperRegex options:NSRegularExpressionSearch].length>0) || ([source rangeOfString:lowerRegex options:NSRegularExpressionSearch].length>0)); - - return isEnglish; - -} - -+ (BOOL)isAllCharacterString:(NSString *)string -{ - NSString *regex = @"[~`!@#$%^&*()_+-=[]|{};':\",./<>?]{,}/";//规定的特殊字符,可以自己随意添加 - - //计算字符串长度 - NSInteger str_length = [string length]; - - NSInteger allIndex = 0; - for (int i = 0; i 1){ - const unichar ls = [substring characterAtIndex:1]; - const int uc = ((hs - 0xd800) * 0x400) + (ls - 0xdc00) + 0x10000; - if (0x1d000 <= uc && uc <= 0x1f918){ - returnValue = YES; - } - } - }else if (substring.length > 1){ - - const unichar ls = [substring characterAtIndex:1]; - if (ls == 0x20e3 || ls == 0xFE0F || ls == 0xd83c){ - returnValue = YES; - } - }else{ - if (0x2100 <= hs && hs <= 0x27ff){ - - if (0x278b <= hs && 0x2792 >= hs){ - returnValue = NO; - }else{ - returnValue = YES; - } - - }else if (0x2B05 <= hs && hs <= 0x2b07){ - returnValue = YES; - }else if (0x2934 <= hs && hs <= 0x2935){ - returnValue = YES; - }else if (0x3297 <= hs && hs <= 0x3299){ - returnValue = YES; - }else if (hs == 0xa9 || hs == 0xae || hs == 0x303d || hs == 0x3030 || hs == 0x2b55 || hs == 0x2b1c || hs == 0x2b1b || hs == 0x2b50 || hs == 0xd83e){ - returnValue = YES; - } - } - - }]; - - return returnValue; -} - - -- (NSString *)RW_stringByTrimmingCharacters{ - return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; -} - -+ (NSString *)chineseTransformToPinyin:(NSString *)chinese{ - CFStringRef hanzi = (__bridge CFStringRef)(chinese); - CFMutableStringRef string = CFStringCreateMutableCopy(NULL, 0, hanzi); - - // Boolean CFStringTransform(CFMutableStringRef string, CFRange *range, CFStringRef transform, Boolean reverse); - //string 为要转换的字符串 - // range 要转换的范围,NULL 则为全部 - //transform 要进行怎么样的转换 //kCFStringTransformMandarinLatin 将汉字转拼音 - //reverse 是否支持逆向转换 - CFStringTransform(string, NULL, kCFStringTransformMandarinLatin, NO); - - //kCFStringTransformStripDiacritics去掉声调 - CFStringTransform(string, NULL, kCFStringTransformStripDiacritics, NO); - - NSString * pinyin = (NSString *) CFBridgingRelease(string); - //将中间分隔符号去掉 - pinyin = [pinyin stringByReplacingOccurrencesOfString:@" " withString: @""]; - - return pinyin; -} - -@end diff --git a/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/UIColor+RW.h b/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/UIColor+RW.h deleted file mode 100644 index 0d8ab365..00000000 --- a/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/UIColor+RW.h +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright © Sud.Tech - * https://sud.tech - */ - -#import - -NS_ASSUME_NONNULL_BEGIN - -#ifndef RGBA -#define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a] -#endif - -#ifndef RGB -#define RGB(r, g, b) RGBA(r, g, b, 1.0f) -#endif - -/* - Create UIColor with a hex string. - Example: UIColorHex(0xF0F), UIColorHex(66ccff), UIColorHex(#66CCFF88) - - Valid format: #RGB #RGBA #RRGGBB #RRGGBBAA 0xRGB ... - The `#` or "0x" sign is not required. - */ -#ifndef UIColorHex -#define UIColorHex(_hex_) [UIColor RW_colorWithHexString:((__bridge NSString *)CFSTR(#_hex_))] -#endif - - -/** - * 所有方法前面全部加pawf_, 避免与其他接入的库的category重名导致未知问题. - * 注: colorWithHexString 与接入的某个库有冲突 - */ -@interface UIColor (RW) - -#pragma mark - Create a UIColor Object -///============================================================================= -/// @name Creating a UIColor Object -///============================================================================= - -/** -Creates and returns a color object using the hex RGB color values. - -@param rgbValue The rgb value such as 0x66ccff. - -@return The color object. The color information represented by this -object is in the device RGB colorspace. -*/ -+ (UIColor *)RW_colorWithRGB:(uint32_t)rgbValue; - -/** - Creates and returns a color object using the hex RGBA color values. - - @param rgbaValue The rgb value such as 0x66ccffff. - -@return The color object. The color information represented by this -object is in the device RGB colorspace. - */ -+ (UIColor *)RW_colorWithRGBA:(uint32_t)rgbaValue; - -/** - Creates and returns a color object using the specified opacity and RGB hex value. - - @param rgbValue The rgb value such as 0x66CCFF. - - @param alpha The opacity value of the color object, - specified as a value from 0.0 to 1.0. - - @return The color object. The color information represented by this - object is in the device RGB colorspace. - */ -+ (UIColor *)RW_colorWithRGB:(uint32_t)rgbValue alpha:(CGFloat)alpha; - -/** - Creates and returns a color object from hex string. - - @discussion: - Valid format: #RGB #RGBA #RRGGBB #RRGGBBAA 0xRGB ... - The `#` or "0x" sign is not required. - The alpha will be set to 1.0 if there is no alpha component. - It will return nil when an error occurs in parsing. - - Example: @"0xF0F", @"66ccff", @"#66CCFF88" - - @param hexStr The hex string value for the new color. - - @return An UIColor object from string, or nil if an error occurs. - */ -+ (nullable UIColor *)RW_colorWithHexString:(NSString *)hexStr; - -@end - -NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/UIColor+RW.m b/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/UIColor+RW.m deleted file mode 100644 index fef81335..00000000 --- a/xplan-ios/Main/Room/View/LittleGame/Presenter/Category/UIColor+RW.m +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright © Sud.Tech - * https://sud.tech - */ - -#import "UIColor+RW.h" -#import "NSString+RW.h" - - -@implementation UIColor (RW) - -+ (UIColor *)RW_colorWithRGB:(uint32_t)rgbValue { - return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0f - green:((rgbValue & 0xFF00) >> 8) / 255.0f - blue:(rgbValue & 0xFF) / 255.0f - alpha:1]; -} - -+ (UIColor *)RW_colorWithRGBA:(uint32_t)rgbaValue { - return [UIColor colorWithRed:((rgbaValue & 0xFF000000) >> 24) / 255.0f - green:((rgbaValue & 0xFF0000) >> 16) / 255.0f - blue:((rgbaValue & 0xFF00) >> 8) / 255.0f - alpha:(rgbaValue & 0xFF) / 255.0f]; -} - -+ (UIColor *)rw_colorWithRGB:(uint32_t)rgbValue alpha:(CGFloat)alpha { - return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0f - green:((rgbValue & 0xFF00) >> 8) / 255.0f - blue:(rgbValue & 0xFF) / 255.0f - alpha:alpha]; -} - -+ (instancetype)RW_colorWithHexString:(NSString *)hexStr { - CGFloat r, g, b, a; - if (hexStrToRGBA(hexStr, &r, &g, &b, &a)) { - return [UIColor colorWithRed:r green:g blue:b alpha:a]; - } - return nil; -} - -static inline NSUInteger hexStrToInt(NSString *str) { - uint32_t result = 0; - sscanf([str UTF8String], "%X", &result); - return result; -} - -static BOOL hexStrToRGBA(NSString *str, - CGFloat *r, CGFloat *g, CGFloat *b, CGFloat *a) { - str = [[str stringByTrim] uppercaseString]; - if ([str hasPrefix:@"#"]) { - str = [str substringFromIndex:1]; - } else if ([str hasPrefix:@"0X"]) { - str = [str substringFromIndex:2]; - } - - NSUInteger length = [str length]; - // RGB RGBA RRGGBB RRGGBBAA - if (length != 3 && length != 4 && length != 6 && length != 8) { - return NO; - } - - //RGB,RGBA,RRGGBB,RRGGBBAA - if (length < 5) { - *r = hexStrToInt([str substringWithRange:NSMakeRange(0, 1)]) / 255.0f; - *g = hexStrToInt([str substringWithRange:NSMakeRange(1, 1)]) / 255.0f; - *b = hexStrToInt([str substringWithRange:NSMakeRange(2, 1)]) / 255.0f; - if (length == 4) *a = hexStrToInt([str substringWithRange:NSMakeRange(3, 1)]) / 255.0f; - else *a = 1; - } else { - *r = hexStrToInt([str substringWithRange:NSMakeRange(0, 2)]) / 255.0f; - *g = hexStrToInt([str substringWithRange:NSMakeRange(2, 2)]) / 255.0f; - *b = hexStrToInt([str substringWithRange:NSMakeRange(4, 2)]) / 255.0f; - if (length == 8) *a = hexStrToInt([str substringWithRange:NSMakeRange(6, 2)]) / 255.0f; - else *a = 1; - } - return YES; -} - - - -@end diff --git a/xplan-ios/Main/Room/View/LittleGame/Presenter/SudCommon.m b/xplan-ios/Main/Room/View/LittleGame/Presenter/SudCommon.m index 49a19890..86d4f9a1 100644 --- a/xplan-ios/Main/Room/View/LittleGame/Presenter/SudCommon.m +++ b/xplan-ios/Main/Room/View/LittleGame/Presenter/SudCommon.m @@ -5,10 +5,9 @@ #import "SudCommon.h" #import -#import "UIColor+RW.h" #import #import - +#import "ThemeColor.h" @implementation SudCommon /// 获取用户名 @@ -84,7 +83,7 @@ + (NSMutableAttributedString *)getAttributedStringWithString:(NSString *)string color:(NSString*)color { NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc]initWithString:string]; - [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor RW_colorWithHexString:color] range:NSMakeRange(0, attributedString.length)]; + [attributedString addAttribute:NSForegroundColorAttributeName value:[ThemeColor colorWithHexString:color] range:NSMakeRange(0, attributedString.length)]; return attributedString; } diff --git a/xplan-ios/Main/Room/View/QuickMessageView/XPRoomQuickMessageContainView.m b/xplan-ios/Main/Room/View/QuickMessageView/XPRoomQuickMessageContainView.m index 312c88fe..670e471b 100644 --- a/xplan-ios/Main/Room/View/QuickMessageView/XPRoomQuickMessageContainView.m +++ b/xplan-ios/Main/Room/View/QuickMessageView/XPRoomQuickMessageContainView.m @@ -13,6 +13,7 @@ #import "AccountInfoStorage.h" #import "XPConstant.h" #import "XCHUDTool.h" +#import "NSArray+Safe.h" ///Model #import "XPMessageRemoteExtModel.h" #import "UserInfoModel.h" @@ -71,13 +72,13 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { XPRoomQuidkMessageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPRoomQuidkMessageCell class]) forIndexPath:indexPath]; if (self.titleArray.count > 0) { - cell.title = self.titleArray[indexPath.row]; + cell.title = [self.titleArray safeObjectAtIndex1:indexPath.row]; } return cell; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { - NSString *str = self.titleArray[indexPath.row]; + NSString *str = [self.titleArray safeObjectAtIndex1:indexPath.row]; NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:12]}; CGSize size = [str boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, 25) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size; return CGSizeMake(size.width + 10, 30); @@ -93,7 +94,7 @@ return; } self.lastSendTime = time2; - NSString *str = self.titleArray[indexPath.row]; + NSString *str = [self.titleArray safeObjectAtIndex1:indexPath.row]; [self sendText:str]; } } diff --git a/xplan-ios/Main/Room/View/RoomRecommend/XPRoomRecommendView.m b/xplan-ios/Main/Room/View/RoomRecommend/XPRoomRecommendView.m index a3433c47..c3db936f 100644 --- a/xplan-ios/Main/Room/View/RoomRecommend/XPRoomRecommendView.m +++ b/xplan-ios/Main/Room/View/RoomRecommend/XPRoomRecommendView.m @@ -11,6 +11,7 @@ ///Tool #import "XPMacro.h" #import "ThemeColor.h" +#import "NSArray+Safe.h" ///View #import "XPRoomInsideRecommendCell.h" #import "XPRoomInsideRecommendEmptyCell.h" @@ -79,8 +80,8 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { XPRoomInsideOperationCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPRoomInsideOperationCell class]) forIndexPath:indexPath]; - cell.title = self.titleArray[indexPath.row]; - cell.imageName = self.imageArray[indexPath.row]; + cell.title = [self.titleArray safeObjectAtIndex1:indexPath.row]; + cell.imageName = [self.imageArray safeObjectAtIndex1:indexPath.row]; return cell; } @@ -112,7 +113,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (self.roomList.count > 0) { XPRoomInsideRecommendCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPRoomInsideRecommendCell class])]; - XPRoomRecommendModel *model = self.roomList[indexPath.row]; + XPRoomRecommendModel *model = [self.roomList safeObjectAtIndex1:indexPath.row]; cell.model = model; return cell; } @@ -126,7 +127,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; if (self.roomList.count > 0) { - XPRoomRecommendModel *model = self.roomList[indexPath.row]; + XPRoomRecommendModel *model = [self.roomList safeObjectAtIndex1:indexPath.row]; if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomRecommendViewJumpToRoom:)]) { [self.delegate xPRoomRecommendViewJumpToRoom:[NSString stringWithFormat:@"%ld", model.uid]]; } diff --git a/xplan-ios/Main/Tabbar/View/TabbarViewController.m b/xplan-ios/Main/Tabbar/View/TabbarViewController.m index 8ac3a33c..2307a8cd 100644 --- a/xplan-ios/Main/Tabbar/View/TabbarViewController.m +++ b/xplan-ios/Main/Tabbar/View/TabbarViewController.m @@ -833,7 +833,9 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; @kStrongify(self); if (finished) { [view removeFromSuperview]; - [self.giftBroadcastQueue removeObjectAtIndex:0]; + if (self.giftBroadcastQueue.count > 0) { + [self.giftBroadcastQueue removeObjectAtIndex:0]; + } if (self.giftBroadcastQueue.count > 0) { [self createGiftBroadcastViewAnimation:self.giftBroadcastQueue.firstObject]; }