优化数组操作,新增 NSMutableArray 的安全方法,包括安全移除、插入和替换对象,确保在索引超出范围时不发生崩溃。更新相关文件以使用新方法,保持代码结构一致性。

This commit is contained in:
edwinQQQ
2025-06-16 17:30:20 +08:00
parent 68ce148abb
commit 8c0276a208
41 changed files with 291 additions and 97 deletions

View File

@@ -288,6 +288,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
///
- (void)createEnterHideAnimation {
NSDictionary * dic= @{@"title":@"隐身进房",
@"isMe":@"",
@"experLevelSeq":@"",
@"effectPath" : @""};
[self.enterRoomAnimationQueue addObject:dic];
@@ -315,7 +316,9 @@ XPRoomGraffitiGiftAnimationViewDelegate
//
NSDictionary *dic = [self.enterRoomAnimationQueue firstObject];
[self.enterRoomAnimationQueue removeObjectAtIndex:0];
if (self.enterRoomAnimationQueue.count > 0) {
[self.enterRoomAnimationQueue xpSafeRemoveObjectAtIndex:0];
}
NSString *title = [dic objectForKey:@"title"];
if ([title isEqualToString:@"隐身进房"]) {
@@ -526,7 +529,9 @@ XPRoomGraffitiGiftAnimationViewDelegate
//
AttachmentModel *nextAttachment = [self.roomBannertModelsQueueV2 firstObject];
[self.roomBannertModelsQueueV2 removeObjectAtIndex:0];
if (self.roomBannertModelsQueueV2.count > 0) {
[self.roomBannertModelsQueueV2 xpSafeRemoveObjectAtIndex:0];
}
//
self.isRoomBannerV2Displaying = YES;
@@ -920,7 +925,9 @@ XPRoomGraffitiGiftAnimationViewDelegate
- (void)nextCarEffect {
if (self.carEffectQueue.count > 0) {
[self.carEffectQueue removeObjectAtIndex:0];
if (self.carEffectQueue.count > 0) {
[self.carEffectQueue xpSafeRemoveObjectAtIndex:0];
}
}
if (self.carEffectQueue.count > 0) {
[self playCarEffect:self.carEffectQueue.firstObject];
@@ -1552,7 +1559,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
}
if (model.enterHide) {
//
if ([message.from isEqualToString:[AccountInfoStorage instance].getUid]) {
if (model.uid == [AccountInfoStorage instance].getUid.integerValue) {
[self createEnterHideAnimation];
}
} else {
@@ -2268,7 +2275,9 @@ XPRoomGraffitiGiftAnimationViewDelegate
- (void)removeFromSvgaQueueAtIndex:(NSInteger)index {
dispatch_async(self.giftEffectsQueue, ^{
if (index < self.svgaQueue.count) {
[self.svgaQueue removeObjectAtIndex:index];
if (index < self.svgaQueue.count) {
[self.svgaQueue xpSafeRemoveObjectAtIndex:index];
}
}
});
}
@@ -2404,7 +2413,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
[tarrowVeiw removeFromSuperview];
self.isPlayOfB = NO;
if (self.animationListB.count > 0) {
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
}
[self playAnimationWithModel];
}
@@ -2455,7 +2464,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
if (finished) {
[luckyGiftEffectView removeFromSuperview];
if (self.animationListB.count > 0) {
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
}
self.isPlayOfB = NO;
[self playAnimationWithModel];
@@ -2510,7 +2519,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
[candyTreeView removeFromSuperview];
self.isPlayOfB = NO;
if (self.animationListB.count > 0) {
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
}
[self playAnimationWithModel];
}
@@ -2566,7 +2575,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
self.isPlayOfB = NO;
[nobleLevelUpView removeFromSuperview];
if (self.animationListB.count > 0) {
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
}
[self playAnimationWithModel];
}
@@ -2620,7 +2629,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
self.isPlayOfB = NO;
if(self.animationListB.count > 0){
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
}
[self playAnimationWithModel];
}
@@ -2658,7 +2667,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
[anchorRankView removeFromSuperview];
self.isPlayOfB = NO;
if(self.animationListB.count > 0){
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
[self playAnimationWithModel];
}
}];
@@ -2730,7 +2739,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
[treasureView removeFromSuperview];
self.isPlayOfB = NO;
if (self.animationListB.count > 0) {
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
}
[self playAnimationWithModel];
}
@@ -2784,7 +2793,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
[tarrowVeiw removeFromSuperview];
self.isPlayOfB = NO;
if (self.animationListB.count > 0) {
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
}
[self playAnimationWithModel];
}
@@ -2821,7 +2830,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
[compoundGiftView removeFromSuperview];
self.isPlayOfB = NO;
if(self.animationListB.count > 0){
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
}
[self playAnimationWithModel];
}
@@ -2860,7 +2869,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
[bannerView removeFromSuperview];
self.isPlayOfB = NO;
if(self.animationListB.count > 0){
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
}
[self playAnimationWithModel];
}];
@@ -2887,7 +2896,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
[bannerView removeFromSuperview];
self.isPlayOfB = NO;
if(self.animationListB.count > 0){
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
}
[self playAnimationWithModel];
}];
@@ -2931,7 +2940,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
[self.universalBannerViewCaches removeObject:bannerView];
self.isPlayOfB = NO;
if(self.animationListB.count > 0){
[self.animationListB removeObjectAtIndex:0];
[self.animationListB xpSafeRemoveObjectAtIndex:0];
}
[self playAnimationWithModel];
}
@@ -3116,7 +3125,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
if (finished) {
[sailingView removeFromSuperview];
if (self.sailingQueue.count > 0) {
[self.sailingQueue removeObjectAtIndex:0];
[self.sailingQueue xpSafeRemoveObjectAtIndex:0];
}
if (self.sailingQueue.count > 0) {
[self createSailingBannerAnimation:self.sailingQueue.firstObject];