From e855f87849f5248dc5d91937ff69af49f1102f74 Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Fri, 11 Nov 2022 15:11:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=81=9A=E6=88=BF=E5=B4=A9?= =?UTF-8?q?=E6=BA=83=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archive/Debug/fir-xplan-ios.png | Bin 1014 -> 1045 bytes xplan-ios.xcodeproj/project.pbxproj | 24 ++++++++++++++++-- xplan-ios/Base/Tool/Safe/NSArray+Safe.h | 16 ++++++++++++ xplan-ios/Base/Tool/Safe/NSArray+Safe.m | 23 +++++++++++++++++ .../Base/Tool/Safe/NSMutableDictionary+Saft.h | 16 ++++++++++++ .../Base/Tool/Safe/NSMutableDictionary+Saft.m | 17 +++++++++++++ xplan-ios/Info.plist | 2 +- xplan-ios/Main/Home/Api/Api+Home.m | 7 +++-- .../Home/View/SubViews/XPHomeLiveHeadView.m | 5 +++- .../Home/View/XPHomeLivesViewController.m | 5 +++- .../Message/View/FindNew/Api/Api+FindNew.m | 8 +++--- .../AnchorView/Model/XPAnchorAttentSendInfo.m | 21 +++++++-------- 12 files changed, 124 insertions(+), 20 deletions(-) create mode 100644 xplan-ios/Base/Tool/Safe/NSArray+Safe.h create mode 100644 xplan-ios/Base/Tool/Safe/NSArray+Safe.m create mode 100644 xplan-ios/Base/Tool/Safe/NSMutableDictionary+Saft.h create mode 100644 xplan-ios/Base/Tool/Safe/NSMutableDictionary+Saft.m diff --git a/archive/Debug/fir-xplan-ios.png b/archive/Debug/fir-xplan-ios.png index 013a63c996564026787fe5f6100de85cf7669e23..5f68f475a906402938acb56539a33a8261045bf6 100644 GIT binary patch delta 1023 zcmV>vFyKFMm%}?UN_pG_Qf>(XR80 z4DaPUyy51x#GtGZYG-dPOjWi|p8WUV`z#On30Gr>kkjRHlOA$@`y%_~$+yj0$jN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|6q7A|G-9-N_N>A3%;2+1&mNM0iVZq##n(2a= z3EsbuMhx>%e*hl*C+|O_`UkoG%}?g(G_y*nm=yjsc<|0!|LNUQrs@*3ss2q%cC<3i zoPTY7Ob7C(;K93py*Pi=Bxh$;Zf<5zmOr)3D(c_BgMY^_&L6cZ9hPDQHZxo6M|*v) zoDBE6>iXcpZ<;UXkE&%IhkhQ@?I{(LYMVFwH}K&9$+w)(-`OY0kZ zB?siE>|`?``PVJ{1MuKK^5v8&J&dPI?^!=qazK8^(?p@d`ETICm;6sTf3zGX;{MxN zzKp@#g)Ep$hgq$;K6vok + +NS_ASSUME_NONNULL_BEGIN + +@interface NSArray (Safe) +-(id)safeObjectAtIndex1:(NSUInteger)index; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/Tool/Safe/NSArray+Safe.m b/xplan-ios/Base/Tool/Safe/NSArray+Safe.m new file mode 100644 index 00000000..3332cb3f --- /dev/null +++ b/xplan-ios/Base/Tool/Safe/NSArray+Safe.m @@ -0,0 +1,23 @@ +// +// NSArray+Safe.m +// xplan-ios +// +// Created by 冯硕 on 2022/11/11. +// + +#import "NSArray+Safe.h" + +@implementation NSArray (Safe) + +-(id)safeObjectAtIndex1:(NSUInteger)index{ + if ([self isKindOfClass:[NSArray class]]){ + if (self.count){ + if (self.count>index){ + return self[index]; + } + } + } + return nil; +} + +@end diff --git a/xplan-ios/Base/Tool/Safe/NSMutableDictionary+Saft.h b/xplan-ios/Base/Tool/Safe/NSMutableDictionary+Saft.h new file mode 100644 index 00000000..0ee34a74 --- /dev/null +++ b/xplan-ios/Base/Tool/Safe/NSMutableDictionary+Saft.h @@ -0,0 +1,16 @@ +// +// NSMutableDictionary+Saft.h +// xplan-ios +// +// Created by 冯硕 on 2022/11/11. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSMutableDictionary (Saft) +- (void)safeSetObject:(id)anObject forKey:(id )aKey; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/Tool/Safe/NSMutableDictionary+Saft.m b/xplan-ios/Base/Tool/Safe/NSMutableDictionary+Saft.m new file mode 100644 index 00000000..0aa28892 --- /dev/null +++ b/xplan-ios/Base/Tool/Safe/NSMutableDictionary+Saft.m @@ -0,0 +1,17 @@ +// +// NSMutableDictionary+Saft.m +// xplan-ios +// +// Created by 冯硕 on 2022/11/11. +// + +#import "NSMutableDictionary+Saft.h" + +@implementation NSMutableDictionary (Saft) + +- (void)safeSetObject:(id)anObject forKey:(id )aKey{ + if (anObject == nil || aKey == nil)return; + [self setObject:anObject forKey:aKey]; +} + +@end diff --git a/xplan-ios/Info.plist b/xplan-ios/Info.plist index 02af50b2..6109f568 100644 --- a/xplan-ios/Info.plist +++ b/xplan-ios/Info.plist @@ -38,7 +38,7 @@ CFBundleVersion - 2022031701 + 2022111001 LSApplicationQueriesSchemes pubgmhd1106467070 diff --git a/xplan-ios/Main/Home/Api/Api+Home.m b/xplan-ios/Main/Home/Api/Api+Home.m index 1e010820..9ae321fa 100644 --- a/xplan-ios/Main/Home/Api/Api+Home.m +++ b/xplan-ios/Main/Home/Api/Api+Home.m @@ -6,6 +6,7 @@ // #import "Api+Home.h" +#import "NSMutableDictionary+Saft.h" @implementation Api (Home) @@ -113,8 +114,10 @@ /// @param uid 用户的uid /// @param rid 进入的类型的id + (void)homePickResource:(HttpRequestHelperCompletion)completion uid:(NSString *)uid rid:(NSString *)rid { - NSDictionary * dic = @{@"uid":uid, @"id":rid}; - [HttpRequestHelper request:@"home/pickResource" method:HttpRequestHelperMethodGET params:dic completion:completion]; + NSMutableDictionary * pararms = [NSMutableDictionary dictionary]; + [pararms safeSetObject:uid forKey:@"uid"]; + [pararms safeSetObject:rid forKey:@"rid"]; + [HttpRequestHelper request:@"home/pickResource" method:HttpRequestHelperMethodGET params:pararms completion:completion]; } diff --git a/xplan-ios/Main/Home/View/SubViews/XPHomeLiveHeadView.m b/xplan-ios/Main/Home/View/SubViews/XPHomeLiveHeadView.m index a1815251..f48d3d64 100644 --- a/xplan-ios/Main/Home/View/SubViews/XPHomeLiveHeadView.m +++ b/xplan-ios/Main/Home/View/SubViews/XPHomeLiveHeadView.m @@ -14,6 +14,7 @@ ///View #import "XPHomeLiveRecordCell.h" #import "StatisticsServiceHelper.h" +#import "NSMutableDictionary+Saft.h" @interface XPHomeLiveHeadView() @@ -94,7 +95,9 @@ if (self.roomList.count > 0) { HomeRecommendRoomModel * liveModel = [self.roomList objectAtIndex:indexPath.item]; if (self.delegate && [self.delegate respondsToSelector:@selector(xPHomeLiveHeadViewDidClickItem:)]) { - [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventRecent_card_click eventAttributes:@{@"roomUid" : liveModel.uid}]; + NSMutableDictionary * dic = [NSMutableDictionary dictionary]; + [dic safeSetObject:liveModel.uid forKey:@"roomUid"]; + [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventRecent_card_click eventAttributes:dic]; [self.delegate xPHomeLiveHeadViewDidClickItem:liveModel]; } } diff --git a/xplan-ios/Main/Home/View/XPHomeLivesViewController.m b/xplan-ios/Main/Home/View/XPHomeLivesViewController.m index 10f8767c..f26d65df 100644 --- a/xplan-ios/Main/Home/View/XPHomeLivesViewController.m +++ b/xplan-ios/Main/Home/View/XPHomeLivesViewController.m @@ -19,6 +19,7 @@ #import "XPHtmlUrl.h" #import "StatisticsServiceHelper.h" #import "XPWeakTimer.h" +#import "NSMutableDictionary+Saft.h" ///Model #import "HomeLiveTagModel.h" #import "HomeLiveLookRecordModel.h" @@ -210,7 +211,9 @@ - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { HomeLiveTagModel *tag = self.tagList[index]; - [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventGebo_tab_click eventAttributes:@{@"geboTagName" : tag.sortName}]; + NSMutableDictionary * dic = [NSMutableDictionary dictionary]; + [dic safeSetObject: tag.sortName forKey:@"geboTagName"]; + [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventGebo_tab_click eventAttributes:dic]; } #pragma mark - JXPagerMainTableViewGestureDelegate diff --git a/xplan-ios/Main/Message/View/FindNew/Api/Api+FindNew.m b/xplan-ios/Main/Message/View/FindNew/Api/Api+FindNew.m index 4b9a73d5..b231c267 100644 --- a/xplan-ios/Main/Message/View/FindNew/Api/Api+FindNew.m +++ b/xplan-ios/Main/Message/View/FindNew/Api/Api+FindNew.m @@ -6,13 +6,15 @@ // #import "Api+FindNew.h" - +#import "NSMutableDictionary+Saft.h" @implementation Api (FindNew) ///发现萌新 + (void)findNewUser:(HttpRequestHelperCompletion)completion { - NSDictionary * dic = @{@"page":@"1", @"pageSize":@"20"}; - [HttpRequestHelper request:@"newbie/poolList" method:HttpRequestHelperMethodGET params:dic completion:completion]; + NSMutableDictionary * pararms = [NSMutableDictionary dictionary]; + [pararms safeSetObject:@"1" forKey:@"page"]; + [pararms safeSetObject:@"20" forKey:@"pageSize"]; + [HttpRequestHelper request:@"newbie/poolList" method:HttpRequestHelperMethodGET params:pararms completion:completion]; } diff --git a/xplan-ios/Main/Room/View/AnchorView/Model/XPAnchorAttentSendInfo.m b/xplan-ios/Main/Room/View/AnchorView/Model/XPAnchorAttentSendInfo.m index 9e086bd5..705edc19 100644 --- a/xplan-ios/Main/Room/View/AnchorView/Model/XPAnchorAttentSendInfo.m +++ b/xplan-ios/Main/Room/View/AnchorView/Model/XPAnchorAttentSendInfo.m @@ -6,19 +6,20 @@ // #import "XPAnchorAttentSendInfo.h" - +#import "NSMutableDictionary+Saft.h" @implementation XPAnchorAttentSendInfo - (NSDictionary *)encodeAttachemt { - - NSDictionary *dict = @{@"uid" :@(self.uid), - @"data":@{ - @"nick":self.nick == nil ? @"" : self.nick, - @"targetUid":@(self.targetUid), - @"targetNick":self.targetNick == nil ? @"" : self.targetNick, - } - }; - return dict; + + NSMutableDictionary * info = [NSMutableDictionary dictionary]; + [info safeSetObject:self.nick forKey:@"nick"]; + [info safeSetObject:@(self.targetUid) forKey:@"targetUid"]; + [info safeSetObject:self.targetNick forKey:@"targetNick"]; + + NSMutableDictionary * dic = [NSMutableDictionary dictionary]; + [dic safeSetObject:@(self.uid) forKey:@"uid"]; + [dic safeSetObject:info forKey:@"data"]; + return info; } @end