From ae24bfd582ee7bf7dfa9ea71fa8576babd5a008a Mon Sep 17 00:00:00 2001 From: linyudan <1031378945@qq.com> Date: Tue, 12 Dec 2023 14:50:44 -0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4tool=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DingDangApp.xcodeproj/project.pbxproj | 68 ++- .../DDCategory/NSCalendar/NSCalendar+DDPick.h | 16 + .../DDCategory/NSCalendar/NSCalendar+DDPick.m | 21 + .../DDCategory/NSDate/NSDate+DDDateUtils.h | 21 + .../DDCategory/NSDate/NSDate+DDDateUtils.m | 76 ++++ .../YYAnimatedImageView+ShowImage.h | 16 + .../YYAnimatedImageView+ShowImage.m | 34 ++ .../DDBaseTool/DDDate/DDDate.h | 101 +++++ .../DDBaseTool/DDDate/DDDate.m | 399 ++++++++++++++++++ .../DDBaseTool/DDDate/DDTimeUtil.h | 54 +++ .../DDBaseTool/DDDate/DDTimeUtil.m | 237 +++++++++++ .../DDSpriteSheeImagetManager.m | 113 +++++ .../DDThirdTool/DDUtility/DDUtility+App.h | 64 --- .../DDThirdTool/DDUtility/DDUtility+Carrier.h | 38 -- .../DDThirdTool/DDUtility/DDUtility+Device.h | 89 ---- .../DDThirdTool/DDUtility/DDUtility+Device.m | 2 +- .../DDThirdTool/DDUtility/DDUtility.h | 165 ++++++++ 17 files changed, 1316 insertions(+), 198 deletions(-) create mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSCalendar/NSCalendar+DDPick.h create mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSCalendar/NSCalendar+DDPick.m create mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSDate/NSDate+DDDateUtils.h create mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSDate/NSDate+DDDateUtils.m create mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/YYAnimatedImageView/YYAnimatedImageView+ShowImage.h create mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/YYAnimatedImageView/YYAnimatedImageView+ShowImage.m create mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDDate.h create mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDDate.m create mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDTimeUtil.h create mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDTimeUtil.m delete mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+App.h delete mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Carrier.h delete mode 100644 yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Device.h diff --git a/yinmeng-ios/DingDangApp.xcodeproj/project.pbxproj b/yinmeng-ios/DingDangApp.xcodeproj/project.pbxproj index c99c088..0b57985 100644 --- a/yinmeng-ios/DingDangApp.xcodeproj/project.pbxproj +++ b/yinmeng-ios/DingDangApp.xcodeproj/project.pbxproj @@ -710,6 +710,11 @@ 8C2C3F202B2801AC002C3C34 /* DDStatisticsService.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F1F2B2801AC002C3C34 /* DDStatisticsService.m */; }; 8C2C3F232B2801D8002C3C34 /* DDStatisticsServiceHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F222B2801D8002C3C34 /* DDStatisticsServiceHelper.m */; }; 8C2C3F272B2803CA002C3C34 /* DDSpriteSheeImagetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F262B2803CA002C3C34 /* DDSpriteSheeImagetManager.m */; }; + 8C2C3F2B2B28CDEF002C3C34 /* DDDate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F2A2B28CDEF002C3C34 /* DDDate.m */; }; + 8C2C3F2E2B28D8B7002C3C34 /* DDTimeUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F2D2B28D8B7002C3C34 /* DDTimeUtil.m */; }; + 8C2C3F322B28DD95002C3C34 /* NSDate+DDDateUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F312B28DD95002C3C34 /* NSDate+DDDateUtils.m */; }; + 8C2C3F362B28DDCE002C3C34 /* NSCalendar+DDPick.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F352B28DDCE002C3C34 /* NSCalendar+DDPick.m */; }; + 8C2C3F3A2B28E22E002C3C34 /* YYAnimatedImageView+ShowImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F392B28E22E002C3C34 /* YYAnimatedImageView+ShowImage.m */; }; 8CE493992B23F44800CA14D5 /* NSMutableDictionary+DDSafe.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CE493982B23F44800CA14D5 /* NSMutableDictionary+DDSafe.m */; }; 8CE4939C2B23F45C00CA14D5 /* NSArray+DDSafe.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CE4939B2B23F45C00CA14D5 /* NSArray+DDSafe.m */; }; 8CE493A02B23F5FA00CA14D5 /* DDUploadFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CE4939F2B23F5FA00CA14D5 /* DDUploadFile.m */; }; @@ -2010,11 +2015,8 @@ 8C2C3F102B27ECEE002C3C34 /* DDCarrierIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDCarrierIdentifier.h; sourceTree = ""; }; 8C2C3F112B27ED3C002C3C34 /* DDUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDUtility.h; sourceTree = ""; }; 8C2C3F122B27ED3C002C3C34 /* DDUtility.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDUtility.m; sourceTree = ""; }; - 8C2C3F142B27ED7C002C3C34 /* DDUtility+App.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DDUtility+App.h"; sourceTree = ""; }; 8C2C3F152B27ED7C002C3C34 /* DDUtility+App.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "DDUtility+App.m"; sourceTree = ""; }; - 8C2C3F172B27F10D002C3C34 /* DDUtility+Device.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DDUtility+Device.h"; sourceTree = ""; }; 8C2C3F182B27F10D002C3C34 /* DDUtility+Device.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "DDUtility+Device.m"; sourceTree = ""; }; - 8C2C3F1A2B27FE43002C3C34 /* DDUtility+Carrier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DDUtility+Carrier.h"; sourceTree = ""; }; 8C2C3F1B2B27FE43002C3C34 /* DDUtility+Carrier.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "DDUtility+Carrier.m"; sourceTree = ""; }; 8C2C3F1E2B2801AC002C3C34 /* DDStatisticsService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDStatisticsService.h; sourceTree = ""; }; 8C2C3F1F2B2801AC002C3C34 /* DDStatisticsService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDStatisticsService.m; sourceTree = ""; }; @@ -2022,6 +2024,16 @@ 8C2C3F222B2801D8002C3C34 /* DDStatisticsServiceHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDStatisticsServiceHelper.m; sourceTree = ""; }; 8C2C3F252B2803CA002C3C34 /* DDSpriteSheeImagetManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDSpriteSheeImagetManager.h; sourceTree = ""; }; 8C2C3F262B2803CA002C3C34 /* DDSpriteSheeImagetManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDSpriteSheeImagetManager.m; sourceTree = ""; }; + 8C2C3F292B28CDEF002C3C34 /* DDDate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDDate.h; sourceTree = ""; }; + 8C2C3F2A2B28CDEF002C3C34 /* DDDate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDDate.m; sourceTree = ""; }; + 8C2C3F2C2B28D8B7002C3C34 /* DDTimeUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDTimeUtil.h; sourceTree = ""; }; + 8C2C3F2D2B28D8B7002C3C34 /* DDTimeUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDTimeUtil.m; sourceTree = ""; }; + 8C2C3F302B28DD95002C3C34 /* NSDate+DDDateUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSDate+DDDateUtils.h"; sourceTree = ""; }; + 8C2C3F312B28DD95002C3C34 /* NSDate+DDDateUtils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSDate+DDDateUtils.m"; sourceTree = ""; }; + 8C2C3F342B28DDCE002C3C34 /* NSCalendar+DDPick.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSCalendar+DDPick.h"; sourceTree = ""; }; + 8C2C3F352B28DDCE002C3C34 /* NSCalendar+DDPick.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSCalendar+DDPick.m"; sourceTree = ""; }; + 8C2C3F382B28E22E002C3C34 /* YYAnimatedImageView+ShowImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "YYAnimatedImageView+ShowImage.h"; sourceTree = ""; }; + 8C2C3F392B28E22E002C3C34 /* YYAnimatedImageView+ShowImage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "YYAnimatedImageView+ShowImage.m"; sourceTree = ""; }; 8CAB97312B2259EA00ED8639 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 8CE493972B23F44800CA14D5 /* NSMutableDictionary+DDSafe.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSMutableDictionary+DDSafe.h"; sourceTree = ""; }; 8CE493982B23F44800CA14D5 /* NSMutableDictionary+DDSafe.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSMutableDictionary+DDSafe.m"; sourceTree = ""; }; @@ -5036,6 +5048,9 @@ 8C2C3ED82B279208002C3C34 /* DDCategory */ = { isa = PBXGroup; children = ( + 8C2C3F372B28E213002C3C34 /* YYAnimatedImageView */, + 8C2C3F332B28DDB9002C3C34 /* NSCalendar */, + 8C2C3F2F2B28DD74002C3C34 /* NSDate */, 8C2C3EF02B27D1D7002C3C34 /* NSObject */, 8C2C3EDB2B279265002C3C34 /* NSString */, 8C2C3EDA2B27924E002C3C34 /* NSArray */, @@ -5124,11 +5139,8 @@ 8C2C3F102B27ECEE002C3C34 /* DDCarrierIdentifier.h */, 8C2C3F112B27ED3C002C3C34 /* DDUtility.h */, 8C2C3F122B27ED3C002C3C34 /* DDUtility.m */, - 8C2C3F142B27ED7C002C3C34 /* DDUtility+App.h */, 8C2C3F152B27ED7C002C3C34 /* DDUtility+App.m */, - 8C2C3F172B27F10D002C3C34 /* DDUtility+Device.h */, 8C2C3F182B27F10D002C3C34 /* DDUtility+Device.m */, - 8C2C3F1A2B27FE43002C3C34 /* DDUtility+Carrier.h */, 8C2C3F1B2B27FE43002C3C34 /* DDUtility+Carrier.m */, ); path = DDUtility; @@ -5154,9 +5166,48 @@ path = DDSpriteSheetManager; sourceTree = ""; }; + 8C2C3F282B28CDBC002C3C34 /* DDDate */ = { + isa = PBXGroup; + children = ( + 8C2C3F292B28CDEF002C3C34 /* DDDate.h */, + 8C2C3F2A2B28CDEF002C3C34 /* DDDate.m */, + 8C2C3F2C2B28D8B7002C3C34 /* DDTimeUtil.h */, + 8C2C3F2D2B28D8B7002C3C34 /* DDTimeUtil.m */, + ); + path = DDDate; + sourceTree = ""; + }; + 8C2C3F2F2B28DD74002C3C34 /* NSDate */ = { + isa = PBXGroup; + children = ( + 8C2C3F302B28DD95002C3C34 /* NSDate+DDDateUtils.h */, + 8C2C3F312B28DD95002C3C34 /* NSDate+DDDateUtils.m */, + ); + path = NSDate; + sourceTree = ""; + }; + 8C2C3F332B28DDB9002C3C34 /* NSCalendar */ = { + isa = PBXGroup; + children = ( + 8C2C3F342B28DDCE002C3C34 /* NSCalendar+DDPick.h */, + 8C2C3F352B28DDCE002C3C34 /* NSCalendar+DDPick.m */, + ); + path = NSCalendar; + sourceTree = ""; + }; + 8C2C3F372B28E213002C3C34 /* YYAnimatedImageView */ = { + isa = PBXGroup; + children = ( + 8C2C3F382B28E22E002C3C34 /* YYAnimatedImageView+ShowImage.h */, + 8C2C3F392B28E22E002C3C34 /* YYAnimatedImageView+ShowImage.m */, + ); + path = YYAnimatedImageView; + sourceTree = ""; + }; 8CE493952B23F2B400CA14D5 /* DDBaseTool */ = { isa = PBXGroup; children = ( + 8C2C3F282B28CDBC002C3C34 /* DDDate */, 8C2C3F242B2803BD002C3C34 /* DDSpriteSheetManager */, 8C2C3F1D2B280186002C3C34 /* DDStatisticsService */, 8C2C3EEB2B27D17C002C3C34 /* DDThirdTool */, @@ -5749,6 +5800,7 @@ 18E659CD2A5655790017854A /* DDSearchRoomCell.m in Sources */, 8C2C3F232B2801D8002C3C34 /* DDStatisticsServiceHelper.m in Sources */, 18660D572A2193C50032D0C9 /* UIView+SDAutoLayout.m in Sources */, + 8C2C3F322B28DD95002C3C34 /* NSDate+DDDateUtils.m in Sources */, 1834018B2A49991700B924BF /* RoomLuckGiftDetailView.m in Sources */, 18D786272A2305E700C9875F /* RoomPopTool.m in Sources */, 181F754B2A5409AB006FA7F5 /* DDGradientView.m in Sources */, @@ -5786,6 +5838,7 @@ 1812EC8D2A54FD9200FF2AC0 /* DDRoomRapidChangeAlertView.m in Sources */, 188EC1372A47CF3300060F03 /* HXPhotoPreviewViewCell.m in Sources */, 188EC1512A47CF3300060F03 /* HXPhotoEditMosaicView.m in Sources */, + 8C2C3F3A2B28E22E002C3C34 /* YYAnimatedImageView+ShowImage.m in Sources */, 186EBFA32A3FE362005623CC /* DDKuoLieModel.m in Sources */, 1838644D2A28A17B005BF235 /* ZLDrawItem.m in Sources */, 18660D542A2193C50032D0C9 /* UIView+Additions.m in Sources */, @@ -5880,6 +5933,7 @@ 188CA96C2A4FCE9600DAFC86 /* DDV2HomeHeaderView.m in Sources */, 189481022A5B90DB005ED591 /* DDSetUserView.m in Sources */, 18CF77DB2A4ECC4A0009B602 /* RoomEventView.m in Sources */, + 8C2C3F2B2B28CDEF002C3C34 /* DDDate.m in Sources */, 186A89202A41ABBA001DE99E /* DDMyAuthorStatusViewController.m in Sources */, 1812EC902A54FDA900FF2AC0 /* DDRoomGiftBottomView.m in Sources */, 186C9D1F2A2A163100209BB5 /* DDLineView.m in Sources */, @@ -6161,6 +6215,7 @@ 186777852A429D0C0096D802 /* RoomBgCollectionViewCell.m in Sources */, 183864382A28A17B005BF235 /* ZLBigImageCell.m in Sources */, 18660D5B2A2193C50032D0C9 /* UILabel+Custom.m in Sources */, + 8C2C3F362B28DDCE002C3C34 /* NSCalendar+DDPick.m in Sources */, 183864432A28A17B005BF235 /* ZLCustomCamera.m in Sources */, 188EC1302A47CF3300060F03 /* HXPhotoView.m in Sources */, 186EBFCD2A4036C0005623CC /* DynamicCommentTableViewCell.m in Sources */, @@ -6254,6 +6309,7 @@ 183864412A28A17B005BF235 /* ZLProgressHUD.m in Sources */, 188EBF6B2A47CEA500060F03 /* DDMListCell.m in Sources */, 18660D6D2A21942F0032D0C9 /* WLBaseCollectionView.m in Sources */, + 8C2C3F2E2B28D8B7002C3C34 /* DDTimeUtil.m in Sources */, 188EC1272A47CF3200060F03 /* HXCameraBottomView.m in Sources */, 18E94E832A275E0A0055E8F0 /* RoomCharmView.m in Sources */, 18660DD12A21E54B0032D0C9 /* RoomToolView.m in Sources */, diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSCalendar/NSCalendar+DDPick.h b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSCalendar/NSCalendar+DDPick.h new file mode 100644 index 0000000..57a1576 --- /dev/null +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSCalendar/NSCalendar+DDPick.h @@ -0,0 +1,16 @@ +// +// NSCalendar+Pick.h +// DingDangApp +// +// Created by 触海 on 2023/12/12. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSCalendar (DDPick) ++ (instancetype)sharedCalendar; +@end + +NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSCalendar/NSCalendar+DDPick.m b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSCalendar/NSCalendar+DDPick.m new file mode 100644 index 0000000..fc779d7 --- /dev/null +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSCalendar/NSCalendar+DDPick.m @@ -0,0 +1,21 @@ +// +// NSCalendar+Pick.m +// DingDangApp +// +// Created by 触海 on 2023/12/12. +// + +#import "NSCalendar+DDPick.h" + +@implementation NSCalendar (DDPick) + ++ (instancetype)sharedCalendar { + static id instance; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [NSCalendar currentCalendar]; + }); + return instance; +} + +@end diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSDate/NSDate+DDDateUtils.h b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSDate/NSDate+DDDateUtils.h new file mode 100644 index 0000000..8cbc4e6 --- /dev/null +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSDate/NSDate+DDDateUtils.h @@ -0,0 +1,21 @@ +// +// NSDate+DDDateUtils.h +// DingDangApp +// +// Created by 触海 on 2023/12/12. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSDate (DDDateUtils) + ++ (NSDateFormatter *)shareDateFormatter; + +- (NSInteger)dd_daysBetween:(NSDate *)aDate; +- (NSDate *)dd_dateByAddingDays:(NSInteger)days; +- (NSString *)dd_stringForFormat:(NSString *)format; +@end + +NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSDate/NSDate+DDDateUtils.m b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSDate/NSDate+DDDateUtils.m new file mode 100644 index 0000000..cf7478d --- /dev/null +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/NSDate/NSDate+DDDateUtils.m @@ -0,0 +1,76 @@ +// +// NSDate+DDDateUtils.m +// DingDangApp +// +// Created by 触海 on 2023/12/12. +// + +#import "NSDate+DDDateUtils.h" +#import "NSCalendar+DDPick.h" + +NSString * const kDateFormatYYYYMMDD = @"yyyy-MM-dd"; +NSString * const kDateFormatYYMMDDTHHmmss = @"yyyy-MM-dd'T'HH:mm:ss"; + +@implementation NSDate (DDDateUtils) ++ (NSDateFormatter *)shareDateFormatter { + static NSDateFormatter *_instance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _instance = [[NSDateFormatter alloc] init]; + [_instance setDateFormat:kDateFormatYYYYMMDD]; + [_instance setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; + }); + return _instance; +} + + +- (NSDate *)dd_dateByAddingDays:(NSInteger)days { + NSCalendar *calendar = [NSCalendar sharedCalendar]; + NSDateComponents *components = [[NSDateComponents alloc] init]; + [components setDay:days]; + return [calendar dateByAddingComponents:components toDate:self options:0]; +} + +- (NSInteger)dd_daysBetween:(NSDate *)aDate { + NSUInteger unitFlags = NSCalendarUnitDay; + NSDate *from = [NSDate dd_at_dateFromString:[self dd_stringForYearMonthDayDashed]]; + NSDate *to = [NSDate dd_at_dateFromString:[aDate dd_stringForYearMonthDayDashed]]; + NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; + NSDateComponents *components = [calendar components:unitFlags fromDate:from toDate:to options:0]; + return labs([components day]) + 1; +} + + + + +#pragma mark - Private Method +- (NSString *)dd_stringForYearMonthDayDashed { + return [self dd_stringForFormat:kDateFormatYYYYMMDD]; +} + +- (NSString *)dd_stringForFormat:(NSString *)format { + if (!format) { + return nil; + } + + NSDateFormatter *formatter = [NSDate shareDateFormatter]; + [formatter setDateFormat:format]; + NSString *timeStr = [formatter stringFromDate:self]; + return timeStr; +} + ++ (NSDate *)dd_at_dateFromString:(NSString *)dateString { + NSDateFormatter *dateFormatter = [self shareDateFormatter]; + if (dateString.length > kDateFormatYYYYMMDD.length) { + [dateFormatter setDateFormat:kDateFormatYYMMDDTHHmmss]; + } else { + [dateFormatter setDateFormat:kDateFormatYYYYMMDD]; + } + NSDate *date = [dateFormatter dateFromString:dateString]; + if (!date) { + date = [NSDate date]; + } + return date; +} + +@end diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/YYAnimatedImageView/YYAnimatedImageView+ShowImage.h b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/YYAnimatedImageView/YYAnimatedImageView+ShowImage.h new file mode 100644 index 0000000..4f1b4fc --- /dev/null +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/YYAnimatedImageView/YYAnimatedImageView+ShowImage.h @@ -0,0 +1,16 @@ +// +// YYAnimatedImageView+ShowImage.h +// DingDangApp +// +// Created by 触海 on 2023/12/12. +// + +#import "YYAnimatedImageView.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface YYAnimatedImageView (ShowImage) + +@end + +NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/YYAnimatedImageView/YYAnimatedImageView+ShowImage.m b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/YYAnimatedImageView/YYAnimatedImageView+ShowImage.m new file mode 100644 index 0000000..dcbd6a3 --- /dev/null +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDCategory/YYAnimatedImageView/YYAnimatedImageView+ShowImage.m @@ -0,0 +1,34 @@ +// +// YYAnimatedImageView+ShowImage.m +// DingDangApp +// +// Created by 触海 on 2023/12/12. +// + +#import "YYAnimatedImageView+ShowImage.h" + +@implementation YYAnimatedImageView (ShowImage) + ++ (void)load { + // 获取系统的方法 + Method displayLayerMethod = class_getInstanceMethod(self, @selector(displayLayer:)); + // 获取更新的方法 + Method displayLayerNewMethod = class_getInstanceMethod(self, @selector(displayLayerNew:)); + // 方法交换 + method_exchangeImplementations(displayLayerMethod, displayLayerNewMethod); +} + + +- (void)displayLayerNew:(CALayer *)layer { + Ivar imageIvar = class_getInstanceVariable([self class], @"_curFrame"); + UIImage *image = object_getIvar(self, imageIvar); + if (image) { + layer.contents = (__bridge id)image.CGImage; + } else { + if (@available(iOS 14.0, *)) { + [super displayLayer:layer]; + } + } +} + +@end diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDDate.h b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDDate.h new file mode 100644 index 0000000..8f64165 --- /dev/null +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDDate.h @@ -0,0 +1,101 @@ +// +// DDDate.h +// DingDangApp +// +// Created by 触海 on 2023/12/12. +// + +#import + +typedef NS_OPTIONS(NSUInteger, DDDayUnit) { + DDDayUnitSunday = 1, + DDDayUnitMonday = 2, + DDDayUnitTuesday = 3, + DDDayUnitWednesday = 4, + DDDayUnitThursday = 5, + DDDayUnitFriday = 6, + DDDayUnitSaturday = 7 +}; + +typedef NS_OPTIONS(NSUInteger, DDMonthUnit) { + DDMonthUnitJanuary = 1, + DDMonthUnitFebruary = 2, + DDMonthUnitMarch = 3, + DDMonthUnitApril = 4, + DDMonthUnitMay = 5, + DDMonthUnitJune = 6, + DDMonthUnitJuly = 7, + DDMonthUnitAugust = 8, + DDMonthUnitSeptember = 9, + DDMonthUnitOctober = 10, + DDMonthUnitNovember = 11, + DDMonthUnitDecember = 12, +}; + +NS_ASSUME_NONNULL_BEGIN + +@interface DDDate : NSObject + + +- (id)initUsingToday; +- (id)initUsingDate:(NSDate *)date; +- (id)initUsingYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day; +- (id)initUsingYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second; +- (id)initUsingString:(NSString *)stringDate; +- (id)initUsingString:(NSString *)stringDate withFormat:(NSString *)dateFormat; +- (id)initUsingSeconds:(NSInteger)seconds; + +- (NSDate *)dd_date; + +- (NSString *)dd_stringValue; +- (NSString *)dd_stringValueWithFormat:(NSString *)dateFormat; + +- (instancetype)dd_zeroTime; + +- (instancetype)dd_previousDay; +- (instancetype)dd_previousDays:(NSInteger)days; +- (instancetype)dd_nextDay; +- (instancetype)dd_nextDays:(NSInteger)days; + +- (instancetype)dd_previousWeek; +- (instancetype)dd_previousWeeks:(NSInteger)weeks; +- (instancetype)dd_nextWeek; +- (instancetype)dd_nextWeeks:(NSInteger)weeks; + +- (instancetype)dd_previousMonth; +- (instancetype)dd_previousMonths:(NSInteger)months; +- (instancetype)dd_nextMonth; +- (instancetype)dd_nextMonths:(NSInteger)months; + +- (instancetype)dd_previousYear; +- (instancetype)dd_previousYears:(NSInteger)years; +- (instancetype)dd_nextYear; +- (instancetype)dd_nextYears:(NSInteger)years; + +- (instancetype)dd_firstDayOfMonth; +- (instancetype)dd_lastDayOfMonth; + +- (instancetype)dd_firstMonthOfYear; +- (instancetype)dd_lastMonthOfYear; + +- (instancetype)dd_previousDayOfDayName:(DDDayUnit)dayUnit; +- (instancetype)dd_nextDayOfDayName:(DDDayUnit)dayUnit; + +- (BOOL)dd_isCurrentDayName:(DDDayUnit)dayUnit; +- (BOOL)dd_isCurrentMonthName:(DDMonthUnit)monthUnit; + +@property NSString *dateFormatUsingString; +@property NSDateFormatterStyle dateFormatUsingStyle; +@property NSDateFormatterStyle timeFormatUsingStyle; +@property NSInteger year; +@property NSInteger month; +@property (readonly) NSInteger week; +@property NSInteger day; +@property NSInteger hour; +@property NSInteger minute; +@property NSInteger second; + + +@end + +NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDDate.m b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDDate.m new file mode 100644 index 0000000..83c92a8 --- /dev/null +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDDate.m @@ -0,0 +1,399 @@ +// +// DDDate.m +// DingDangApp +// +// Created by 触海 on 2023/12/12. +// + +#import "DDDate.h" + +@implementation DDDate { + NSDateFormatter *_dateFormatter; + NSCalendar *_calendar; + NSDate *_date; + NSCalendarUnit _dateTimeCalendarUnit; +} + + +#pragma mark - Init +- (id)init { + if (self = [super init]) { + _dateFormatter = [[NSDateFormatter alloc] init]; + _dateFormatter.dateStyle = NSDateFormatterFullStyle; + _dateFormatter.timeStyle = NSDateFormatterFullStyle; + + _calendar = [NSCalendar currentCalendar]; + _date = [[NSDate alloc] init]; + + _dateTimeCalendarUnit = (NSCalendarUnitYear | NSCalendarUnitMonth | NSWeekCalendarUnit | NSCalendarUnitWeekday | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond); + + } + return self; +} + +- (id)initUsingToday { + if (self = [self init]) { + _date = [NSDate date]; + } + return self; +} + +- (id)initUsingString:(NSString *)stringDate { + if (self = [self init]) { + _date = [_dateFormatter dateFromString:stringDate]; + } + return self; +} + +- (id)initUsingString:(NSString *)stringDate withFormat:(NSString *)dateFormat { + if (self = [self init]) { + _dateFormatter.dateFormat = dateFormat; + _date = [_dateFormatter dateFromString:stringDate]; + } + return self; +} + +- (id)initUsingYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day { + if (self = [self init]) { + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.year = year; + dateComponents.month = month; + dateComponents.day = day; + _date = [_calendar dateFromComponents:dateComponents]; + } + return self; +} + +- (id)initUsingYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second { + if (self = [self init]) { + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.year = year; + dateComponents.month = month; + dateComponents.day = day; + dateComponents.hour = hour; + dateComponents.minute = minute; + dateComponents.second = second; + _date = [_calendar dateFromComponents:dateComponents]; + } + return self; +} + +- (id)initUsingDate:(NSDate *)date { + if (self = [self init]) { + _date = date; + } + return self; +} + +- (id)initUsingSeconds:(NSInteger)seconds { + if (self = [self init]) { + _date = [NSDate dateWithTimeIntervalSinceReferenceDate:seconds]; + } + return self; +} + + +- (NSDate *)dd_date { + return _date; +} + +- (NSString *)dd_stringValue { + return [_dateFormatter stringFromDate:_date]; +} + +- (NSString *)dd_stringValueWithFormat:(NSString *)dateFormat { + NSDateFormatter *localDateFormatter = [_dateFormatter copy]; + localDateFormatter.dateFormat = dateFormat; + + return [localDateFormatter stringFromDate:_date]; +} + +- (instancetype)dd_zeroTime { + NSDateComponents *dateComponents = [_calendar components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond) fromDate:_date]; + dateComponents.hour = 0; + dateComponents.minute = 0; + dateComponents.second = 0; + + _date = [_calendar dateFromComponents:dateComponents]; + + return self; +} + +- (void)setDateFormatUsingString:(NSString *)dateFormatUsingString { + _dateFormatter.dateFormat = dateFormatUsingString; +} + +- (NSString *)dateFormatUsingString { + return _dateFormatter.dateFormat; +} + +- (void)setDateFormatUsingStyle:(NSDateFormatterStyle)dateFormatUsingStyle { + _dateFormatter.dateStyle = dateFormatUsingStyle; +} + +- (NSDateFormatterStyle)dateFormatUsingStyle { + return _dateFormatter.dateStyle; +} + +- (void)setTimeFormatUsingStyle:(NSDateFormatterStyle)timeFormatUsingStyle { + _dateFormatter.timeStyle = timeFormatUsingStyle; +} + +- (NSDateFormatterStyle)timeFormatUsingStyle { + return _dateFormatter.timeStyle; +} + +- (instancetype)daysCalculate:(NSInteger)days isForward:(BOOL)isForward { + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.day = days * (isForward ? 1 : -1); + _date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0]; + + return self; +} + +- (instancetype)dd_previousDay { + return [self dd_previousDays:1]; +} + +- (instancetype)dd_previousDays:(NSInteger)days { + return [self daysCalculate:days isForward:NO]; +} + +- (instancetype)dd_nextDay { + return [self dd_nextDays:1]; +} + +- (instancetype)dd_nextDays:(NSInteger)days { + return [self daysCalculate:days isForward:YES]; +} + +- (instancetype)weeksCalculate:(NSInteger)weeks isForward:(BOOL)isForward { + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.day = (7 * weeks) * (isForward ? 1 : -1); + _date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0]; + + return self; +} + +- (instancetype)dd_previousWeek { + return [self dd_previousWeeks:1]; +} + +- (instancetype)dd_previousWeeks:(NSInteger)weeks { + return [self weeksCalculate:weeks isForward:NO]; +} + +- (instancetype)dd_nextWeek { + return [self dd_nextWeeks:1]; +} + +- (instancetype)dd_nextWeeks:(NSInteger)weeks { + return [self weeksCalculate:weeks isForward:YES]; +} + +- (instancetype)monthsCalculate:(NSInteger)months isForward:(BOOL)isForward { + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.month = months * (isForward ? 1 : -1); + _date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0]; + + return self; +} + +- (instancetype)dd_previousMonth { + return [self dd_previousMonths:1]; +} + +- (instancetype)dd_previousMonths:(NSInteger)months { + return [self monthsCalculate:months isForward:NO]; +} + +- (instancetype)dd_nextMonth { + return [self dd_nextMonths:1]; +} + +- (instancetype)dd_nextMonths:(NSInteger)months { + return [self monthsCalculate:months isForward:YES]; +} + +- (instancetype)yearsCalculate:(NSInteger)years isForward:(BOOL)isForward { + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + dateComponents.year = years * (isForward ? 1 : -1); + _date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0]; + + return self; +} + +- (instancetype)dd_previousYear { + return [self dd_previousYears:1]; +} + +- (instancetype)dd_previousYears:(NSInteger)years { + return [self yearsCalculate:years isForward:NO]; +} + +- (instancetype)dd_nextYear { + return [self dd_nextYears:1]; +} + +- (instancetype)dd_nextYears:(NSInteger)years { + return [self yearsCalculate:years isForward:YES]; +} + +- (instancetype)dd_firstDayOfMonth { + NSDateComponents *dateComponents = [_calendar components:_dateTimeCalendarUnit fromDate:_date]; + dateComponents.day = 1; + _date = [_calendar dateFromComponents:dateComponents]; + + return self; +} + +- (instancetype)dd_lastDayOfMonth { + NSDateComponents *dateComponents; + NSDate *date; + + dateComponents = [_calendar components:_dateTimeCalendarUnit fromDate:_date]; + dateComponents.day = 1; + date = [_calendar dateFromComponents:dateComponents]; + dateComponents = [[NSDateComponents alloc] init]; + dateComponents.month = 1; + date = [_calendar dateByAddingComponents:dateComponents toDate:date options:0]; + dateComponents = [[NSDateComponents alloc] init]; + dateComponents.day = -1; + _date = [_calendar dateByAddingComponents:dateComponents toDate:date options:0]; + + return self; +} + +- (instancetype)dd_firstMonthOfYear { + NSDateComponents *dateComponents = [_calendar components:_dateTimeCalendarUnit fromDate:_date]; + dateComponents.month = DDMonthUnitJanuary; + _date = [_calendar dateFromComponents:dateComponents]; + + return self; +} + +- (instancetype)dd_lastMonthOfYear { + NSDateComponents *dateComponents = [_calendar components:_dateTimeCalendarUnit fromDate:_date]; + dateComponents.month = DDMonthUnitDecember; + _date = [_calendar dateFromComponents:dateComponents]; + + return self; +} + +- (instancetype)dd_previousDayOfDayName:(DDDayUnit)dayUnit { + NSInteger currentWeekDay = [_calendar components:_dateTimeCalendarUnit fromDate:_date].weekday; + + if (currentWeekDay == dayUnit) + return [self dd_previousWeek]; + + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + + if (currentWeekDay > dayUnit) + dateComponents.day = -(currentWeekDay - dayUnit); + else + dateComponents.day = -currentWeekDay - (7 - dayUnit); + + _date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0]; + + return self; +} + +- (instancetype)dd_nextDayOfDayName:(DDDayUnit)dayUnit { + NSInteger currentWeekDay = [_calendar components:_dateTimeCalendarUnit fromDate:_date].weekday; + + if (currentWeekDay == dayUnit) + return [self dd_nextWeek]; + + NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; + + if (currentWeekDay < dayUnit) + dateComponents.day = dayUnit - currentWeekDay; + else + dateComponents.day = -currentWeekDay + dayUnit; + + _date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0]; + + return self; +} + +- (BOOL)dd_isCurrentDayName:(DDDayUnit)dayUnit { + return ([_calendar components:_dateTimeCalendarUnit fromDate:_date].weekday == dayUnit); +} + +- (BOOL)dd_isCurrentMonthName:(DDMonthUnit)monthUnit { + return ([_calendar components:_dateTimeCalendarUnit fromDate:_date].month == monthUnit); +} + + +#pragma mark - Set && Get +- (NSInteger)year { + return [_calendar components:_dateTimeCalendarUnit fromDate:_date].year; +} + +- (void)setYear:(NSInteger)year { + NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date]; + components.year = year; + + _date = [_calendar dateFromComponents:components]; +} + +- (NSInteger)month { + return [_calendar components:_dateTimeCalendarUnit fromDate:_date].month; +} + +- (void)setMonth:(NSInteger)month { + NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date]; + components.month = month; + + _date = [_calendar dateFromComponents:components]; +} + +- (NSInteger)week { + return [_calendar components:_dateTimeCalendarUnit fromDate:_date].weekday; +} + +- (NSInteger)day { + return [_calendar components:_dateTimeCalendarUnit fromDate:_date].day; +} + +- (void)setDay:(NSInteger)day { + NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date]; + components.day = day; + + _date = [_calendar dateFromComponents:components]; +} + +- (NSInteger)hour { + return [_calendar components:_dateTimeCalendarUnit fromDate:_date].hour; +} + +- (void)setHour:(NSInteger)hour { + NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date]; + components.hour = hour; + + _date = [_calendar dateFromComponents:components]; +} + +- (NSInteger)minute { + return [_calendar components:_dateTimeCalendarUnit fromDate:_date].minute; +} + +- (void)setMinute:(NSInteger)minute { + NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date]; + components.minute = minute; + + _date = [_calendar dateFromComponents:components]; +} + +- (NSInteger)second { + return [_calendar components:_dateTimeCalendarUnit fromDate:_date].second; +} + +- (void)setSecond:(NSInteger)second { + NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date]; + components.second = second; + + _date = [_calendar dateFromComponents:components]; +} + +@end diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDTimeUtil.h b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDTimeUtil.h new file mode 100644 index 0000000..8a582e4 --- /dev/null +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDTimeUtil.h @@ -0,0 +1,54 @@ +// +// DDTimeUtil.h +// DingDangApp +// +// Created by 触海 on 2023/12/12. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface DDTimeUtil : NSObject + +/** + * 根据秒数获取倒计时时间 + * @param second 秒 + * @return 格式为 01:02:00 + */ ++ (NSString *)DD_GetTimeWithSecond:(NSUInteger)second; + ++ (NSDate *)DD_GetDateWithCompleteTime:(NSString *)time; + ++ (NSDate *)DD_GetDateWithTime:(NSString *)time; + ++ (NSDate *)DD_GetDateWithYMD:(NSString *)time; + ++ (NSString *)DD_GetDateWithHHMMSS:(NSString *)time; + ++ (NSString *)DD_GetDateWithYYMMDD:(NSString *)time; + ++ (NSString *)DD_GetDateWithYYMM:(NSString *)time; + ++ (NSString *)DD_GetDateWithMMDD:(NSString *)time; + ++ (NSDate *)DD_GetDateWithYearMonthDay:(NSString *)time; + ++ (NSString *)DD_GetMonthDayContent:(NSDate *)date; + ++ (NSString *)DD_GetYYMMWithDate:(NSDate *)date; + ++ (NSString *)DD_GetYYMMDDWithDate:(NSDate *)date; + ++ (NSString *)DD_GetYYMMDDWithDateFormatter:(NSDate *)date; + ++ (NSString *)DD_GetDateWithTotalTimeWith:(NSString *)time; + ++ (NSString *)DD_GetNowTimeTimestampMillisecond; + +///比较两个时间的差值 ++ (NSDateComponents *)DD_CompareTwoDate:(NSDate *)firstDate secondDate:(NSDate *)secondDate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDTimeUtil.m b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDTimeUtil.m new file mode 100644 index 0000000..058b4bc --- /dev/null +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDDate/DDTimeUtil.m @@ -0,0 +1,237 @@ +// +// DDTimeUtil.m +// DingDangApp +// +// Created by 触海 on 2023/12/12. +// + +#import "DDTimeUtil.h" +#import "DDDate.h" +#import "DDUtility.h" + +@implementation DDTimeUtil + ++ (NSString *)DD_GetTimeWithSecond:(NSUInteger)second { + NSUInteger hours = second / 3600; + NSUInteger minutes = (second % 3600) / 60; + NSUInteger seconds = second % 60; + return [NSString stringWithFormat:@"%@:%@:%@",[self DD_GetConent:hours], + [self DD_GetConent:minutes],[self DD_GetConent:seconds]]; +} + ++ (NSString *)DD_GetConent:(NSUInteger)count { + if(count >= 10){ + return [NSString stringWithFormat:@"%lu",(unsigned long)count]; + } + return [NSString stringWithFormat:@"0%lu",(unsigned long)count]; +} + ++(NSDate *)DD_GetDateWithYMD:(NSString *)time { + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateFormat:@"yyyy:MM:dd"]; + NSDate* date = [dateFormatter dateFromString:time]; + return date; +} + ++(NSDate *)DD_GetDateWithYearMonthDay:(NSString *)time { + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateFormat:@"yyyy-MM-dd"]; + NSDate* date = [dateFormatter dateFromString:time]; + return date; +} + ++ (NSDate *)DD_GetDateWithCompleteTime:(NSString *)time { + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateFormat:@"yyyy:MM:dd HH:mm:ss"]; + NSDate* date = [dateFormatter dateFromString:time]; + return date; +} + ++ (NSDate *)DD_GetDateWithTime:(NSString *)time { + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateFormat:@"HH:mm:ss"]; + NSDate* date = [dateFormatter dateFromString:time]; + return date; +} + + ++ (NSString *)DD_GetMonthDayContent:(NSDate *)date { + DDDate *currentDate = [[DDDate alloc] initUsingDate:date]; + NSString *month = [self DD_GetContent:currentDate.month]; + NSString *day = [self DD_GetContent:currentDate.day]; + + NSString *content = [NSString stringWithFormat:@"%@-%@",month,day]; + return content; +} + + + ++ (NSString *)DD_GetYYMMDDWithDate:(NSDate *)date { + NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; + NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"]; + [formatter setTimeZone:timeZone]; + formatter.dateFormat = @"yyyy-MM-dd"; + NSString *dateStr = [formatter stringFromDate:date]; + return dateStr; +} + ++ (NSString *)DD_GetYYMMDDWithDateFormatter:(NSDate *)date { + NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; + NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"]; + [formatter setTimeZone:timeZone]; + formatter.dateFormat = @"yyyy年MM月dd日"; + NSString *dateStr = [formatter stringFromDate:date]; + return dateStr; +} + + ++ (NSString *)DD_GetYYMMWithDate:(NSDate *)date { + NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; + NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"]; + [formatter setTimeZone:timeZone]; + formatter.dateFormat = @"YYYY年MM月"; + NSString *dateStr = [formatter stringFromDate:date]; + return dateStr; +} + + ++ (NSString *)DD_GetDateWithYYMMDD:(NSString *)time { + NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; + formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"]; + [formatter setDateStyle:NSDateFormatterMediumStyle]; + [formatter setTimeStyle:NSDateFormatterShortStyle]; + [formatter setDateFormat:@"YYYY年MM月dd日"]; + // 毫秒值转化为秒 + NSString * times; + if ([self is32bit] && [[DDUtility DD_SystemVersion] floatValue] <= 10.0) { + times = [NSString stringWithFormat:@"%f", ([time doubleValue] + 3600 * 1000 * 8)]; + }else{ + times = time; + } + NSDate* date = [NSDate dateWithTimeIntervalSince1970:[times longLongValue]/ 1000.0]; + NSString* dateString = [formatter stringFromDate:date]; + return dateString; +} + ++ (NSString *)DD_GetDateWithYYMM:(NSString *)time { + NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; + formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"]; + [formatter setDateStyle:NSDateFormatterMediumStyle]; + [formatter setTimeStyle:NSDateFormatterShortStyle]; + [formatter setDateFormat:@"yyyy年MM月"]; + // 毫秒值转化为秒 + NSString * times; + if ([self is32bit] && [[DDUtility DD_SystemVersion] floatValue] <= 10.0) { + times = [NSString stringWithFormat:@"%f", ([time doubleValue] + 3600 * 1000 * 8)]; + }else{ + times = time; + } + NSDate* date = [NSDate dateWithTimeIntervalSince1970:[times doubleValue]/ 1000.0]; + NSString* dateString = [formatter stringFromDate:date]; + return dateString; +} + ++ (NSString *)DD_GetDateWithMMDD:(NSString *)time { + NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; + formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"]; + [formatter setDateStyle:NSDateFormatterMediumStyle]; + [formatter setTimeStyle:NSDateFormatterShortStyle]; + [formatter setDateFormat:@"MM月dd日"]; + // 毫秒值转化为秒 + NSString * times; + if ([self is32bit] && [[DDUtility DD_SystemVersion] floatValue] <= 10.0) { + times = [NSString stringWithFormat:@"%f", ([time doubleValue] + 3600 * 1000 * 8)]; + }else{ + times = time; + } + NSDate* date = [NSDate dateWithTimeIntervalSince1970:[times doubleValue]/ 1000.0]; + NSString* dateString = [formatter stringFromDate:date]; + return dateString; +} + + ++ (NSString *)DD_GetDateWithHHMMSS:(NSString *)time { + NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; + formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"]; + [formatter setDateStyle:NSDateFormatterMediumStyle]; + [formatter setTimeStyle:NSDateFormatterShortStyle]; + [formatter setDateFormat:@"HH:mm:ss"]; + // 毫秒值转化为秒 + NSString * times; + if ([self is32bit] && [[DDUtility DD_SystemVersion] floatValue] <= 10.0) { + times = [NSString stringWithFormat:@"%f", ([time doubleValue] + 3600 * 1000 * 8)]; + }else{ + times = time; + } + NSDate* date = [NSDate dateWithTimeIntervalSince1970:[times doubleValue]/ 1000.0]; + NSString* dateString = [formatter stringFromDate:date]; + return dateString; +} + ++ (NSString *)DD_GetDateWithTotalTimeWith:(NSString *)time { + NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; + formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"]; + [formatter setDateStyle:NSDateFormatterMediumStyle]; + [formatter setTimeStyle:NSDateFormatterShortStyle]; + [formatter setDateFormat:@"yyyy.MM.dd HH:mm:ss"]; + // 毫秒值转化为秒 + NSString * times; + if ([self is32bit] && [[DDUtility DD_SystemVersion] floatValue] <= 10.0) { + times = [NSString stringWithFormat:@"%f", ([time doubleValue] + 3600 * 1000 * 8)]; + }else{ + times = time; + } + NSDate* date = [NSDate dateWithTimeIntervalSince1970:[times doubleValue]/ 1000.0]; + NSString* dateString = [formatter stringFromDate:date]; + return dateString; +} + + ++ (NSString *)DD_GetNowTimeTimestampMillisecond { + + NSDateFormatter *formatter = [[NSDateFormatter alloc] init] ; + [formatter setDateStyle:NSDateFormatterMediumStyle]; + [formatter setTimeStyle:NSDateFormatterShortStyle]; + //设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制 + [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; + //设置时区,这个对于时间的处理有时很重要 + NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"]; + [formatter setTimeZone:timeZone]; + NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0]; + NSTimeInterval a=[dat timeIntervalSince1970]*1000; + NSString * timeSp = [NSString stringWithFormat:@"%.0f", a]; + + return timeSp; +} + + ++ (NSDateComponents *)DD_CompareTwoDate:(NSDate *)firstDate secondDate:(NSDate *)secondDate { + // 当前日历 + NSCalendar *calendar = [NSCalendar currentCalendar]; + // 需要对比的时间数据 + NSCalendarUnit unit = NSCalendarUnitYear | NSCalendarUnitMonth + | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond; + // 对比时间差 + NSDateComponents *dateCom = [calendar components:unit fromDate:firstDate toDate:secondDate options:0]; + return dateCom; +} + +#pragma mark - Private Method ++ (NSString *)DD_GetContent:(NSUInteger)count { + if(count >= 10){ + return [NSString stringWithFormat:@"%lu",(unsigned long)count]; + } + return [NSString stringWithFormat:@"0%lu",(unsigned long)count]; +} + ++ (BOOL)is32bit { +#if defined(__LP64__) && __LP64__ + return NO; +#else + return YES; +#endif +} + +@end + + diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDSpriteSheetManager/DDSpriteSheeImagetManager.m b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDSpriteSheetManager/DDSpriteSheeImagetManager.m index 8f81959..787df2d 100644 --- a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDSpriteSheetManager/DDSpriteSheeImagetManager.m +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDSpriteSheetManager/DDSpriteSheeImagetManager.m @@ -6,6 +6,9 @@ // #import "DDSpriteSheeImagetManager.h" +#import "DDSystemTool.h" +#import "DDGCDHelper.h" + @interface DDSpriteSheeImagetManager() @property (nonatomic,strong) YYSpriteSheetImage *sprite; @@ -14,13 +17,123 @@ @property (nonatomic, strong) UIImageView *operationImageView; @end +static NSInteger retryCount = 3; +static CGFloat kDeafultFrameDurations = 0.066; + @implementation DDSpriteSheeImagetManager +#pragma mark - Public Method /// 下载 SpriteSheetImage - (void)dd_loadSpriteSheetImageWithURL:(NSURL *)url completionBlock:(void (^)(YYSpriteSheetImage * _Nullable))completionBlock failureBlock:(void (^)(NSError * _Nullable))failureBlock { + if (!url) return; + + __weak typeof(self) weakSelf = self; + [self dd_cacheURL:url]; + [self.operationImageView sd_setImageWithURL:url completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { + __strong typeof(self) strongSelf = weakSelf; + if (error) { + if (![self.retryCache objectForKey:[DDSystemTool DD_GetDeviceUUid]]) { + [self.retryCache setObject:@(0) forKey:[DDSystemTool DD_GetDeviceUUid]]; + } + + NSInteger value = [[self.retryCache objectForKey:[DDSystemTool DD_GetDeviceUUid]] integerValue]; + [self.retryCache setObject:@(value) forKey:[DDSystemTool DD_GetDeviceUUid]]; + + if (value < retryCount) { + [self dd_retryWithKey:[DDSystemTool DD_GetDeviceUUid] complete:^(YYSpriteSheetImage *sprit) { + completionBlock(sprit); + } failure:^(NSError *error) { + failureBlock(error); + }]; + } + + return; + } + + YYSpriteSheetImage *sheetImage = [DDSpriteSheeImagetManager DD_SpriteSheet:image frameDurations:kDeafultFrameDurations]; + dd_dispatch_main_sync_safe(^{ + if (sheetImage) { + completionBlock(sheetImage); + [self dd_removeCacheWithKey:[DDSystemTool DD_GetDeviceUUid]]; + [self.retryCache removeObjectForKey:[DDSystemTool DD_GetDeviceUUid]]; + } + }); + + }]; } + +#pragma mark - Private Method +- (void)dd_cacheURL:(NSURL *)url { + NSString *key = [DDSystemTool DD_GetDeviceUUid]; + [self.parserQueue setObject:url forKey:key]; +} + +- (void)dd_removeCacheWithKey:(NSString *)key { + [self.parserQueue removeObjectForKey:key]; +} + +- (void)dd_retryWithKey:(NSString *)key + complete:(void(^)(YYSpriteSheetImage *))complete + failure:(void(^)(NSError *))failure { + if(!key) return; + + NSURL *url = [self.parserQueue objectForKey:[DDSystemTool DD_GetDeviceUUid]]; + [self dd_loadSpriteSheetImageWithURL:url completionBlock:^(YYSpriteSheetImage * _Nullable sprit) { + complete(sprit); + } failureBlock:^(NSError * _Nullable error) { + failure(error); + }]; +} + +/*** 这里与UI 协定 一张横向长图 每个帧 都是通过高度 来获取 正方形 frameDurations 帧长 **/ ++ (YYSpriteSheetImage *)DD_SpriteSheet:(UIImage *)image frameDurations:(CGFloat)frameDurations { + NSMutableArray *contentRects = [NSMutableArray array]; + NSMutableArray *durations = [NSMutableArray array]; + + CGFloat imageHeight = image.size.height; + NSInteger spriteCount = image.size.width/imageHeight; + + for (int i = 0; i < spriteCount; i++) { + CGRect rect; + rect.size = CGSizeMake(imageHeight, imageHeight); + rect.origin.x = imageHeight * i; + rect.origin.y = 0; + [contentRects addObject:[NSValue valueWithCGRect:rect]]; + if (!frameDurations) { + frameDurations = kDeafultFrameDurations; + } + [durations addObject:@(frameDurations)]; + } + + YYSpriteSheetImage *sheetImage = [[YYSpriteSheetImage alloc] initWithSpriteSheetImage:image contentRects:contentRects frameDurations:durations loopCount:0]; + return sheetImage; + +} + +#pragma mark - Get +- (NSMutableDictionary *)parserQueue { + if (!_parserQueue) { + _parserQueue = [NSMutableDictionary dictionary]; + } + return _parserQueue; +} + +- (NSMutableDictionary *)retryCache { + if (!_retryCache) { + _retryCache = [NSMutableDictionary dictionary]; + } + return _retryCache; +} + +- (UIImageView *)operationImageView { + if (!_operationImageView) { + _operationImageView = [[UIImageView alloc] init]; + } + return _operationImageView; +} + @end diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+App.h b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+App.h deleted file mode 100644 index e6fe9d5..0000000 --- a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+App.h +++ /dev/null @@ -1,64 +0,0 @@ -// -// DDUtility+App.h -// DingDangApp -// -// Created by 触海 on 2023/12/11. -// - -#import "DDUtility.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface DDUtility (App) -/** - * 从YYMobile-Info.plist中读取字段 - * @param key 键 - * @return 值 - */ -+ (id)DD_ValueInPlistForKey:(NSString *)key; - -/*** 获取App版本号, 从plist从读取CFBundleShortVersion */ -+ (NSString *)DD_AppVersion; - -/*** 获取AppBuild号, 从plist中读取CFBundleVersion */ -+ (NSString *)DD_AppBuild; - -/*** 当前构建出的版本在svn中的版本号 */ -+ (NSString *)DD_SvnVersion; - -/** - 获取appName - @return app的名称 - */ -+ (NSString *)DD_AppName; - -/** - * 获取bundle id - * @return bundle id - */ -+ (NSString *)DD_AppBundleId; - -/*** 获取YYMobileFrameworkRes.bundle的URL */ -+ (NSURL *)DD_URLForMobileFrameworkResourceBundle; - -/*** 获取YYMobileFrameworkRes.bundle的路径 */ -+ (NSString *)DD_PathForMobileFrameworkResourceBundle; - -+ (BOOL)DD_AddSkipBackupAttributeToItemAtURL:(NSURL *)fileURL; - -/** - * 获取当前的构建类型(DEBUG/RELEASE) - * @return 构建类型 - */ -+ (NSString *)DD_BuildType; - -/*** 获取平台渠道 */ -+ (NSString *)DD_GetAppSource; - -/*** 是否来自appstore */ -+ (BOOL)DD_IsFromAppStore; - - -@end - -NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Carrier.h b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Carrier.h deleted file mode 100644 index a4dc3c3..0000000 --- a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Carrier.h +++ /dev/null @@ -1,38 +0,0 @@ -// -// DDUtility+Carrier.h -// DingDangApp -// -// Created by 触海 on 2023/12/11. -// - -#import "DDUtility.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface DDUtility (Carrier) - -/** - 获取设备唯一标识 - @return 唯一标识 - */ -+ (NSString *)DD_DeviceUniqueIdentification; - -/*** 获取运营商 */ -+ (CTCarrier *)DD_Carrier; - -/*** 获取运营商类型 */ -+ (NSInteger)DD_CarrierIdentifier; - -/*** 获取运营商名称 */ -+ (NSString *)DD_CarrierName; - -/** - * 从CTCarrier对象获取网络类型 - * @param carrier - CTCarrier对象 - * @return CarrierType - */ -+ (NSInteger)DD_IdentifierOfCarrier:(CTCarrier *)carrier; - -@end - -NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Device.h b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Device.h deleted file mode 100644 index c9847e3..0000000 --- a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Device.h +++ /dev/null @@ -1,89 +0,0 @@ -// -// DDUtility+Device.h -// DingDangApp -// -// Created by 触海 on 2023/12/11. -// - -#import "DDUtility.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface DDUtility (Device) - -/*** 获取modelName, 如iPhone5,2 */ -+ (NSString *)DD_ModelName; - -/** - 获取设备类型 - @return 设备类型 - */ -+ (NSString*)DD_ModelType; - -/*** 获取系统版本 */ -+ (NSString *)DD_SystemVersion; - -/*** 获取当前设备的 IDFV,IDFV 在某些情况下会变,不建议将其作为设备标识 */ -+ (NSString *)DD_IdentifierForVendor NS_AVAILABLE_IOS(6_0); - -/** - * 获取当前的设备标识,会使用海度 SDK 中的 OpenUDID - * @return 海度 SDK 缓存的 OpenUDID - */ -+ (NSString *)DD_DeviceID; - -/*** 获取当前网络状态 */ -+ (NSInteger)DD_NetworkStatus; - -/*** 获取当前IP地址 */ -+ (NSString *)DD_IPAddress; - -/** - * 获取当前IP地址 - * @param preferIPv4 优先取IPv4的地址 - */ -+ (NSString *)DD_IPAddress:(BOOL)preferIPv4; - -/** - * 检查Camera是否可用, 可用则调用available; 若隐私设置中禁用了本app对相机 - * 的访问, 则调用denied; 否则视为被限制, 调用restriction - * @param available 可用 - * @param denied 不可用 - * @param restriction 受限制 - */ -+ (void)DD_CheckCameraAvailable:(void (^)(void))available denied:(void(^)(void))denied restriction:(void(^)(void))restriction; - -/** - * 检查相册是否可用, 可用则调用available; 若隐私设置中禁用了本app对相册 - * 的访问, 则调用denied; 否则视为被限制, 调用restriction - * @param available 可用 - * @param denied 不可用 - * @param restriction 受限制 - */ -+ (void)DD_CheckAssetsLibrayAvailable:(void (^)(void))available denied:(void(^)(void))denied restriction:(void(^)(void))restriction; - -/** - 检查麦克风权限 - @param resultBlock 结果处理block - */ -+ (void)DD_CheckMicPrivacy:(void(^)(BOOL succeed))resultBlock; - -+ (NSString *)DD_MACAddresss; -+ (NSString *)DD_IDFA; - -/** - * 初始化信令sdk,imsdk所用到的appName - * @return app name - */ -+ (NSString *)DD_AppName; - - -/** - 当前设备是否低于, 等于 iPhone6 - @return 当前设备是否低于, 等于 iPhone6 - */ -+ (BOOL)DD_ISIphone6AndLow; - -@end - -NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Device.m b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Device.m index 839057c..0f4cb45 100644 --- a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Device.m +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility+Device.m @@ -5,7 +5,7 @@ // Created by 触海 on 2023/12/11. // -#import "DDUtility+Device.h" +#import "DDUtility.h" #import #import #import diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility.h b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility.h index 3619bf5..5bf94cf 100644 --- a/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility.h +++ b/yinmeng-ios/DingDangApp/YingMeng/DDBaseCompilation/DDBaseTool/DDThirdTool/DDUtility/DDUtility.h @@ -17,5 +17,170 @@ NS_ASSUME_NONNULL_BEGIN @end +/*==============================*/ +/* App Utilities */ +/*==============================*/ +@interface DDUtility (App) +/** + * 从YYMobile-Info.plist中读取字段 + * @param key 键 + * @return 值 + */ ++ (id)DD_ValueInPlistForKey:(NSString *)key; + +/*** 获取App版本号, 从plist从读取CFBundleShortVersion */ ++ (NSString *)DD_AppVersion; + +/*** 获取AppBuild号, 从plist中读取CFBundleVersion */ ++ (NSString *)DD_AppBuild; + +/*** 当前构建出的版本在svn中的版本号 */ ++ (NSString *)DD_SvnVersion; + +/** + 获取appName + @return app的名称 + */ ++ (NSString *)DD_AppName; + +/** + * 获取bundle id + * @return bundle id + */ ++ (NSString *)DD_AppBundleId; + +/*** 获取YYMobileFrameworkRes.bundle的URL */ ++ (NSURL *)DD_URLForMobileFrameworkResourceBundle; + +/*** 获取YYMobileFrameworkRes.bundle的路径 */ ++ (NSString *)DD_PathForMobileFrameworkResourceBundle; + ++ (BOOL)DD_AddSkipBackupAttributeToItemAtURL:(NSURL *)fileURL; + +/** + * 获取当前的构建类型(DEBUG/RELEASE) + * @return 构建类型 + */ ++ (NSString *)DD_BuildType; + +/*** 获取平台渠道 */ ++ (NSString *)DD_GetAppSource; + +/*** 是否来自appstore */ ++ (BOOL)DD_IsFromAppStore; + + +@end + + +/*==============================*/ +/* Carrier Utilities */ +/*==============================*/ +@interface DDUtility (Carrier) + +/** + 获取设备唯一标识 + @return 唯一标识 + */ ++ (NSString *)DD_DeviceUniqueIdentification; + +/*** 获取运营商 */ ++ (CTCarrier *)DD_Carrier; + +/*** 获取运营商类型 */ ++ (NSInteger)DD_CarrierIdentifier; + +/*** 获取运营商名称 */ ++ (NSString *)DD_CarrierName; + +/** + * 从CTCarrier对象获取网络类型 + * @param carrier - CTCarrier对象 + * @return CarrierType + */ ++ (NSInteger)DD_IdentifierOfCarrier:(CTCarrier *)carrier; + +@end + + +/*==============================*/ +/* Device Utilities */ +/*==============================*/ +@interface DDUtility (Device) + +/*** 获取modelName, 如iPhone5,2 */ ++ (NSString *)DD_ModelName; + +/** + 获取设备类型 + @return 设备类型 + */ ++ (NSString*)DD_ModelType; + +/*** 获取系统版本 */ ++ (NSString *)DD_SystemVersion; + +/*** 获取当前设备的 IDFV,IDFV 在某些情况下会变,不建议将其作为设备标识 */ ++ (NSString *)DD_IdentifierForVendor NS_AVAILABLE_IOS(6_0); + +/** + * 获取当前的设备标识,会使用海度 SDK 中的 OpenUDID + * @return 海度 SDK 缓存的 OpenUDID + */ ++ (NSString *)DD_DeviceID; + +/*** 获取当前网络状态 */ ++ (NSInteger)DD_NetworkStatus; + +/*** 获取当前IP地址 */ ++ (NSString *)DD_IPAddress; + +/** + * 获取当前IP地址 + * @param preferIPv4 优先取IPv4的地址 + */ ++ (NSString *)DD_IPAddress:(BOOL)preferIPv4; + +/** + * 检查Camera是否可用, 可用则调用available; 若隐私设置中禁用了本app对相机 + * 的访问, 则调用denied; 否则视为被限制, 调用restriction + * @param available 可用 + * @param denied 不可用 + * @param restriction 受限制 + */ ++ (void)DD_CheckCameraAvailable:(void (^)(void))available denied:(void(^)(void))denied restriction:(void(^)(void))restriction; + +/** + * 检查相册是否可用, 可用则调用available; 若隐私设置中禁用了本app对相册 + * 的访问, 则调用denied; 否则视为被限制, 调用restriction + * @param available 可用 + * @param denied 不可用 + * @param restriction 受限制 + */ ++ (void)DD_CheckAssetsLibrayAvailable:(void (^)(void))available denied:(void(^)(void))denied restriction:(void(^)(void))restriction; + +/** + 检查麦克风权限 + @param resultBlock 结果处理block + */ ++ (void)DD_CheckMicPrivacy:(void(^)(BOOL succeed))resultBlock; + ++ (NSString *)DD_MACAddresss; ++ (NSString *)DD_IDFA; + +/** + * 初始化信令sdk,imsdk所用到的appName + * @return app name + */ ++ (NSString *)DD_AppName; + + +/** + 当前设备是否低于, 等于 iPhone6 + @return 当前设备是否低于, 等于 iPhone6 + */ ++ (BOOL)DD_ISIphone6AndLow; + +@end NS_ASSUME_NONNULL_END