diff --git a/.DS_Store b/.DS_Store index 542713c..4d873c3 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Ifish.xcodeproj/project.pbxproj b/Ifish.xcodeproj/project.pbxproj index 0ace8fd..530bb67 100644 --- a/Ifish.xcodeproj/project.pbxproj +++ b/Ifish.xcodeproj/project.pbxproj @@ -2251,6 +2251,26 @@ 88F5EFD81D48D08100CC7CAF /* MMVectorImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5EF591D48D08100CC7CAF /* MMVectorImage.m */; }; 88F5EFD91D48D08100CC7CAF /* MyControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F5EF5C1D48D08100CC7CAF /* MyControl.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 88F740C01ECC28E800876AED /* ShopAddGoodsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F740BF1ECC28E800876AED /* ShopAddGoodsViewController.m */; }; + C024B79E2379668B00509424 /* NSArray+AvoidCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = C024B78A2379668B00509424 /* NSArray+AvoidCrash.m */; }; + C024B79F2379668B00509424 /* AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B78B2379668B00509424 /* AvoidCrash.h */; }; + C024B7A02379668B00509424 /* NSString+AvoidCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = C024B78C2379668B00509424 /* NSString+AvoidCrash.m */; }; + C024B7A12379668B00509424 /* NSDictionary+AvoidCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = C024B78D2379668B00509424 /* NSDictionary+AvoidCrash.m */; }; + C024B7A22379668B00509424 /* NSAttributedString+AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B78E2379668B00509424 /* NSAttributedString+AvoidCrash.h */; }; + C024B7A32379668B00509424 /* NSMutableDictionary+AvoidCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = C024B78F2379668B00509424 /* NSMutableDictionary+AvoidCrash.m */; }; + C024B7A42379668B00509424 /* NSMutableString+AvoidCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = C024B7902379668B00509424 /* NSMutableString+AvoidCrash.m */; }; + C024B7A52379668B00509424 /* NSObject+AvoidCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = C024B7912379668B00509424 /* NSObject+AvoidCrash.m */; }; + C024B7A62379668B00509424 /* NSMutableArray+AvoidCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = C024B7922379668B00509424 /* NSMutableArray+AvoidCrash.m */; }; + C024B7A72379668B00509424 /* NSMutableAttributedString+AvoidCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = C024B7932379668B00509424 /* NSMutableAttributedString+AvoidCrash.m */; }; + C024B7A82379668B00509424 /* NSAttributedString+AvoidCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = C024B7942379668B00509424 /* NSAttributedString+AvoidCrash.m */; }; + C024B7A92379668B00509424 /* NSDictionary+AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B7952379668B00509424 /* NSDictionary+AvoidCrash.h */; }; + C024B7AA2379668B00509424 /* NSString+AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B7962379668B00509424 /* NSString+AvoidCrash.h */; }; + C024B7AB2379668B00509424 /* AvoidCrash.m in Sources */ = {isa = PBXBuildFile; fileRef = C024B7972379668B00509424 /* AvoidCrash.m */; }; + C024B7AC2379668B00509424 /* NSArray+AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B7982379668B00509424 /* NSArray+AvoidCrash.h */; }; + C024B7AD2379668B00509424 /* NSMutableDictionary+AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B7992379668B00509424 /* NSMutableDictionary+AvoidCrash.h */; }; + C024B7AE2379668B00509424 /* NSObject+AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B79A2379668B00509424 /* NSObject+AvoidCrash.h */; }; + C024B7AF2379668B00509424 /* NSMutableString+AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B79B2379668B00509424 /* NSMutableString+AvoidCrash.h */; }; + C024B7B02379668B00509424 /* NSMutableAttributedString+AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B79C2379668B00509424 /* NSMutableAttributedString+AvoidCrash.h */; }; + C024B7B12379668B00509424 /* NSMutableArray+AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B79D2379668B00509424 /* NSMutableArray+AvoidCrash.h */; }; C0F0400C23756F3C00B61D3B /* ExternalAccessory.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0F0400B23756F3C00B61D3B /* ExternalAccessory.framework */; }; CB0F4E8622951A130091C76D /* SVRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = CB0F4E7B22951A130091C76D /* SVRadialGradientLayer.m */; }; CB0F4E8722951A130091C76D /* SVIndefiniteAnimatedView.h in Headers */ = {isa = PBXBuildFile; fileRef = CB0F4E7C22951A130091C76D /* SVIndefiniteAnimatedView.h */; }; @@ -5657,6 +5677,26 @@ 88F5EF5C1D48D08100CC7CAF /* MyControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyControl.m; sourceTree = ""; }; 88F740BE1ECC28E800876AED /* ShopAddGoodsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShopAddGoodsViewController.h; sourceTree = ""; }; 88F740BF1ECC28E800876AED /* ShopAddGoodsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShopAddGoodsViewController.m; sourceTree = ""; }; + C024B78A2379668B00509424 /* NSArray+AvoidCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+AvoidCrash.m"; sourceTree = ""; }; + C024B78B2379668B00509424 /* AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AvoidCrash.h; sourceTree = ""; }; + C024B78C2379668B00509424 /* NSString+AvoidCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+AvoidCrash.m"; sourceTree = ""; }; + C024B78D2379668B00509424 /* NSDictionary+AvoidCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+AvoidCrash.m"; sourceTree = ""; }; + C024B78E2379668B00509424 /* NSAttributedString+AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSAttributedString+AvoidCrash.h"; sourceTree = ""; }; + C024B78F2379668B00509424 /* NSMutableDictionary+AvoidCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableDictionary+AvoidCrash.m"; sourceTree = ""; }; + C024B7902379668B00509424 /* NSMutableString+AvoidCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableString+AvoidCrash.m"; sourceTree = ""; }; + C024B7912379668B00509424 /* NSObject+AvoidCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+AvoidCrash.m"; sourceTree = ""; }; + C024B7922379668B00509424 /* NSMutableArray+AvoidCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableArray+AvoidCrash.m"; sourceTree = ""; }; + C024B7932379668B00509424 /* NSMutableAttributedString+AvoidCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableAttributedString+AvoidCrash.m"; sourceTree = ""; }; + C024B7942379668B00509424 /* NSAttributedString+AvoidCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSAttributedString+AvoidCrash.m"; sourceTree = ""; }; + C024B7952379668B00509424 /* NSDictionary+AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+AvoidCrash.h"; sourceTree = ""; }; + C024B7962379668B00509424 /* NSString+AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+AvoidCrash.h"; sourceTree = ""; }; + C024B7972379668B00509424 /* AvoidCrash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AvoidCrash.m; sourceTree = ""; }; + C024B7982379668B00509424 /* NSArray+AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+AvoidCrash.h"; sourceTree = ""; }; + C024B7992379668B00509424 /* NSMutableDictionary+AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableDictionary+AvoidCrash.h"; sourceTree = ""; }; + C024B79A2379668B00509424 /* NSObject+AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+AvoidCrash.h"; sourceTree = ""; }; + C024B79B2379668B00509424 /* NSMutableString+AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableString+AvoidCrash.h"; sourceTree = ""; }; + C024B79C2379668B00509424 /* NSMutableAttributedString+AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableAttributedString+AvoidCrash.h"; sourceTree = ""; }; + C024B79D2379668B00509424 /* NSMutableArray+AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableArray+AvoidCrash.h"; sourceTree = ""; }; C0F0400B23756F3C00B61D3B /* ExternalAccessory.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ExternalAccessory.framework; path = System/Library/Frameworks/ExternalAccessory.framework; sourceTree = SDKROOT; }; CB0F4E7B22951A130091C76D /* SVRadialGradientLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVRadialGradientLayer.m; sourceTree = ""; }; CB0F4E7C22951A130091C76D /* SVIndefiniteAnimatedView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVIndefiniteAnimatedView.h; sourceTree = ""; }; @@ -11923,6 +11963,7 @@ 88F5EEE81D48D04100CC7CAF /* libs */ = { isa = PBXGroup; children = ( + C024B7892379668B00509424 /* AvoidCrash */, CB484CE822B76DEC0075F050 /* GWP2PSDK */, CB7D6AEA2296A1870014E5C7 /* AliPush */, CB7D6A9722953BEB0014E5C7 /* YYCache */, @@ -12114,6 +12155,33 @@ path = Reachability; sourceTree = ""; }; + C024B7892379668B00509424 /* AvoidCrash */ = { + isa = PBXGroup; + children = ( + C024B78A2379668B00509424 /* NSArray+AvoidCrash.m */, + C024B78B2379668B00509424 /* AvoidCrash.h */, + C024B78C2379668B00509424 /* NSString+AvoidCrash.m */, + C024B78D2379668B00509424 /* NSDictionary+AvoidCrash.m */, + C024B78E2379668B00509424 /* NSAttributedString+AvoidCrash.h */, + C024B78F2379668B00509424 /* NSMutableDictionary+AvoidCrash.m */, + C024B7902379668B00509424 /* NSMutableString+AvoidCrash.m */, + C024B7912379668B00509424 /* NSObject+AvoidCrash.m */, + C024B7922379668B00509424 /* NSMutableArray+AvoidCrash.m */, + C024B7932379668B00509424 /* NSMutableAttributedString+AvoidCrash.m */, + C024B7942379668B00509424 /* NSAttributedString+AvoidCrash.m */, + C024B7952379668B00509424 /* NSDictionary+AvoidCrash.h */, + C024B7962379668B00509424 /* NSString+AvoidCrash.h */, + C024B7972379668B00509424 /* AvoidCrash.m */, + C024B7982379668B00509424 /* NSArray+AvoidCrash.h */, + C024B7992379668B00509424 /* NSMutableDictionary+AvoidCrash.h */, + C024B79A2379668B00509424 /* NSObject+AvoidCrash.h */, + C024B79B2379668B00509424 /* NSMutableString+AvoidCrash.h */, + C024B79C2379668B00509424 /* NSMutableAttributedString+AvoidCrash.h */, + C024B79D2379668B00509424 /* NSMutableArray+AvoidCrash.h */, + ); + path = AvoidCrash; + sourceTree = ""; + }; CB0F4E622294F2B00091C76D /* Networking */ = { isa = PBXGroup; children = ( @@ -12608,6 +12676,7 @@ files = ( FAA732D0227B2F7C0062C252 /* SetTimerModel.h in Headers */, CBA6167C228F9AB100ED380D /* MASUtilities.h in Headers */, + C024B7A92379668B00509424 /* NSDictionary+AvoidCrash.h in Headers */, 3D1C50F8221A9EE00096AE43 /* des2.h in Headers */, CB484E0422B8C8C80075F050 /* bprint.h in Headers */, FAFC08232279CB5900B5A07B /* SetTimerCell.h in Headers */, @@ -12632,6 +12701,7 @@ 3D1C5116221A9EE00096AE43 /* KTPhotoView+SDWebImage.h in Headers */, 3D1C50BB221A9EE00096AE43 /* RegisterResult.h in Headers */, CBA6167F228F9AB100ED380D /* MASViewConstraint.h in Headers */, + C024B7A22379668B00509424 /* NSAttributedString+AvoidCrash.h in Headers */, CB8B6468230F7F980032EB24 /* IfishMainInfoCell.h in Headers */, CB484E1122B8C8C90075F050 /* version.h in Headers */, 3D1C5122221A9EE00096AE43 /* IfishRecVideoViewCell.h in Headers */, @@ -12654,6 +12724,7 @@ CB484E0B22B8C8C80075F050 /* version.h in Headers */, CB484E1722B8C8C90075F050 /* dxva2.h in Headers */, CB484DE622B8C8C80075F050 /* sha.h in Headers */, + C024B7AA2379668B00509424 /* NSString+AvoidCrash.h in Headers */, FAA732D8227C1DA80062C252 /* Xuanduo2TimerModel.h in Headers */, 3D1C50DC221A9EE00096AE43 /* PAIOUnit.h in Headers */, CB7D6AA322953BEB0014E5C7 /* YYMemoryCache.h in Headers */, @@ -12719,6 +12790,7 @@ 3D1C5115221A9EE00096AE43 /* ShotScreenImgViewController.h in Headers */, 3D1C5083221A9EDF0096AE43 /* KTThumbsViewController.h in Headers */, 3D1C50AF221A9EDF0096AE43 /* YFonc.h in Headers */, + C024B7AD2379668B00509424 /* NSMutableDictionary+AvoidCrash.h in Headers */, CB484E0222B8C8C80075F050 /* mem.h in Headers */, CB484DD922B8C8C80075F050 /* elian.h in Headers */, CB4820562334E30300A50C92 /* HKPieChartView.h in Headers */, @@ -12741,6 +12813,8 @@ 3D1C5088221A9EDF0096AE43 /* KTThumbsView.h in Headers */, 3D1C513F221A9EE10096AE43 /* FishControlThreedViewCell.h in Headers */, FA0892F52270BED00084A609 /* XuanduoHuliModel.h in Headers */, + C024B79F2379668B00509424 /* AvoidCrash.h in Headers */, + C024B7AE2379668B00509424 /* NSObject+AvoidCrash.h in Headers */, 3D1C50C7221A9EE00096AE43 /* LocalDevice.h in Headers */, 3D1C50A0221A9EDF0096AE43 /* TouchButton.h in Headers */, CBB0243723517947002900D5 /* MJExtension.h in Headers */, @@ -12755,13 +12829,16 @@ CBB0243923517947002900D5 /* MJPropertyKey.h in Headers */, CBA61681228F9AB100ED380D /* NSLayoutConstraint+MASDebugAdditions.h in Headers */, 3D1C5109221A9EE00096AE43 /* P2PPlaybackController.h in Headers */, + C024B7B02379668B00509424 /* NSMutableAttributedString+AvoidCrash.h in Headers */, CB484DE422B8C8C80075F050 /* base64.h in Headers */, CB484E1922B8C8C90075F050 /* FfmpegInterface.h in Headers */, CB4820842334E99700A50C92 /* IQToolbar.h in Headers */, 3D1C50B9221A9EDF0096AE43 /* CheckNewMessageResult.h in Headers */, CB4820932334E99700A50C92 /* IQUIScrollView+Additions.h in Headers */, CB48208E2334E99700A50C92 /* IQUIViewController+Additions.h in Headers */, + C024B7AC2379668B00509424 /* NSArray+AvoidCrash.h in Headers */, CB48207D2334E99700A50C92 /* IQUIView+IQKeyboardToolbar.h in Headers */, + C024B7AF2379668B00509424 /* NSMutableString+AvoidCrash.h in Headers */, CB48208A2334E99700A50C92 /* IQKeyboardReturnKeyHandler.h in Headers */, CBA61678228F9AB100ED380D /* NSArray+MASShorthandAdditions.h in Headers */, 3D1C5095221A9EDF0096AE43 /* Alarm.h in Headers */, @@ -12833,6 +12910,7 @@ CB484DF122B8C8C80075F050 /* adler32.h in Headers */, 3D1C50A9221A9EDF0096AE43 /* MXSCycleScrollView.h in Headers */, CB484E0322B8C8C80075F050 /* parseutils.h in Headers */, + C024B7B12379668B00509424 /* NSMutableArray+AvoidCrash.h in Headers */, CB484DF822B8C8C80075F050 /* random_seed.h in Headers */, CBA6167B228F9AB100ED380D /* NSArray+MASAdditions.h in Headers */, CBA61688228F9AB100ED380D /* Masonry.h in Headers */, @@ -14311,6 +14389,7 @@ 881671CB1EA5DE2B00BEBF23 /* UMComEditForwardView.m in Sources */, 883E76271D4897570030E075 /* DeviceModel.m in Sources */, 881B12401E1CCB8A004C074B /* RusunHaveHeateSetViewController.m in Sources */, + C024B7A32379668B00509424 /* NSMutableDictionary+AvoidCrash.m in Sources */, 88140AAC1D86C10D00FE34E5 /* IfishUDPBroadCastHelper.m in Sources */, 3D1C5130221A9EE10096AE43 /* IfishCameraRecordFourCell.m in Sources */, 883E78661D48A5E50030E075 /* ConnectInfoCollectionModel.m in Sources */, @@ -14538,6 +14617,7 @@ 883BCD6F1ED555F20046283B /* IFishVideoPalyViewController.m in Sources */, 883283841EAF43BA00A47157 /* AIyuYanXuanViewController.m in Sources */, 886B806E1D6310F000E1B9B3 /* certificationViewFirstCell.m in Sources */, + C024B7A02379668B00509424 /* NSString+AvoidCrash.m in Sources */, 881671B11EA5DE2B00BEBF23 /* UMComLoginViewController.m in Sources */, 88F5EFC11D48D08100CC7CAF /* FMDatabaseQueue.m in Sources */, 88C1B2BA1DD1745500C2C99A /* LXAdScrollView.m in Sources */, @@ -14603,6 +14683,7 @@ 88C1B1FB1DCB6E8700C2C99A /* IfishNewsModel.m in Sources */, 88673B041E1F6A4F001D5F49 /* SongNuoBDProtocol.m in Sources */, CB0F4E8622951A130091C76D /* SVRadialGradientLayer.m in Sources */, + C024B7A82379668B00509424 /* NSAttributedString+AvoidCrash.m in Sources */, 3D1C5114221A9EE00096AE43 /* KTThumbView+SDWebImage.m in Sources */, 88645B1B1E83B81E00234DB4 /* IfishInfoDetailPingLunCell.m in Sources */, 881671B31EA5DE2B00BEBF23 /* UMComRegisterViewController.m in Sources */, @@ -14769,11 +14850,13 @@ 88D3373C1DC7440C006C0ADB /* IfishConnectingView.m in Sources */, 8856B0EC1DED4AE0009D384A /* IfishUserDefaultHelper.m in Sources */, 881671C41EA5DE2B00BEBF23 /* UMComTableViewCell.m in Sources */, + C024B7AB2379668B00509424 /* AvoidCrash.m in Sources */, 3D1C50DA221A9EE00096AE43 /* RecommendInfo.m in Sources */, 883E79B21D48B0280030E075 /* MerchantCell.m in Sources */, 883E76421D4897570030E075 /* TimerSateModel.m in Sources */, CB484CF922B8B0AC0075F050 /* GCDAsyncUdpSocket.m in Sources */, 881869341D6FDD3B00CE9DFF /* ShopKanHuP2PViewController.m in Sources */, + C024B79E2379668B00509424 /* NSArray+AvoidCrash.m in Sources */, CBA6168C228F9AB100ED380D /* MASViewAttribute.m in Sources */, 88602DB91E10D97E00F3DB5D /* UIButton+WebCache.m in Sources */, 883E762F1D4897570030E075 /* TemperatureSetModel.m in Sources */, @@ -14805,6 +14888,7 @@ 881671D61EA5DE2B00BEBF23 /* UMComSysCommentCell.m in Sources */, 885C43B31E89F79D00685A2E /* IfishLiveListViewCell.m in Sources */, CB4820902334E99700A50C92 /* IQUIScrollView+Additions.m in Sources */, + C024B7A62379668B00509424 /* NSMutableArray+AvoidCrash.m in Sources */, 881671D51EA5DE2B00BEBF23 /* UMComChatRecodTableViewCell.m in Sources */, 883E76241D4897570030E075 /* DropViewModel.m in Sources */, 8891330A1ECE999A00F52EBC /* IfishShopGoodsVideoRecordViewController.m in Sources */, @@ -14879,14 +14963,17 @@ 880707FE1DE6C18A0076F65A /* KanKanListDataHelper.m in Sources */, 88F5EFA91D48D08100CC7CAF /* AFHTTPRequestOperation.m in Sources */, 3D1C50CF221A9EE00096AE43 /* ConnectFailurePromptView.m in Sources */, + C024B7A52379668B00509424 /* NSObject+AvoidCrash.m in Sources */, CB5B9B1922EEC4BC00F0DFB1 /* UIView+Toast.m in Sources */, 883E78441D48A5E50030E075 /* KeLiAiBackmassageDataUnity.m in Sources */, 881671AF1EA5DE2B00BEBF23 /* UMComUserAlbumDataController.m in Sources */, 881671B01EA5DE2B00BEBF23 /* UMComLoginManager.m in Sources */, + C024B7A12379668B00509424 /* NSDictionary+AvoidCrash.m in Sources */, 88F5EE4C1D48CA2800CC7CAF /* ESP_ByteUtil.m in Sources */, 883E79C61D48B0280030E075 /* SetCell.m in Sources */, 881671E71EA5DE2B00BEBF23 /* UMComAddedImageCellView.m in Sources */, 881672181EA5DE2B00BEBF23 /* UMComSimpleGridViewerController.m in Sources */, + C024B7A42379668B00509424 /* NSMutableString+AvoidCrash.m in Sources */, 88F5EFCA1D48D08100CC7CAF /* JHRefreshHeaderView.m in Sources */, 88F5EFAC1D48D08100CC7CAF /* AFNetworkReachabilityManager.m in Sources */, 883E783B1D48A5E50030E075 /* StoreViewController.m in Sources */, @@ -15120,6 +15207,7 @@ CB7D6AA222953BEB0014E5C7 /* YYCache.m in Sources */, 883E79B91D48B0280030E075 /* LYHelper.m in Sources */, 886185CA1EF2290000459AD1 /* FourControlNameViewController.m in Sources */, + C024B7A72379668B00509424 /* NSMutableAttributedString+AvoidCrash.m in Sources */, 881F0F541D73DF680091507E /* BaoGaoViewSecondCell.m in Sources */, 883E78491D48A5E50030E075 /* NoneControlNonetimerViewController.m in Sources */, 880707451DDD3EF50076F65A /* P2PShareView1Cell.m in Sources */, diff --git a/Ifish/.DS_Store b/Ifish/.DS_Store index bc3a80d..4739c77 100644 Binary files a/Ifish/.DS_Store and b/Ifish/.DS_Store differ diff --git a/Ifish/AppDelegate.m b/Ifish/AppDelegate.m index b88f5c2..3f2cc2a 100644 --- a/Ifish/AppDelegate.m +++ b/Ifish/AppDelegate.m @@ -80,6 +80,7 @@ //阿里百川 #import #import "IfishADTimerViewController.h" +#import "AvoidCrash.h" @interface AppDelegate () @property(nonatomic,strong)ICSDrawerController*ics; @@ -169,7 +170,9 @@ if (data != nil) { [self sendExceptionLogWithData:data path:dataPath]; }*/ - +#ifdef __OPTIMIZE__ + [AvoidCrash becomeEffective]; +#endif //短信验证 [SMSSDK registerApp:SMSSDK_APPKey withSecret:SMSSDK_APPSec]; [SMSSDK enableAppContactFriends:NO]; diff --git a/Ifish/Assets.xcassets/.DS_Store b/Ifish/Assets.xcassets/.DS_Store index 507938a..415c6c0 100644 Binary files a/Ifish/Assets.xcassets/.DS_Store and b/Ifish/Assets.xcassets/.DS_Store differ diff --git a/Ifish/Assets.xcassets/热点链接/apcoonetc.imageset/Contents.json b/Ifish/Assets.xcassets/热点链接/apcoonetc.imageset/Contents.json new file mode 100644 index 0000000..a170885 --- /dev/null +++ b/Ifish/Assets.xcassets/热点链接/apcoonetc.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "apcoonetc.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Ifish/Assets.xcassets/热点链接/apcoonetc.imageset/apcoonetc.png b/Ifish/Assets.xcassets/热点链接/apcoonetc.imageset/apcoonetc.png new file mode 100644 index 0000000..4b7cbe7 Binary files /dev/null and b/Ifish/Assets.xcassets/热点链接/apcoonetc.imageset/apcoonetc.png differ diff --git a/Ifish/AvoidCrash/AvoidCrash.h b/Ifish/AvoidCrash/AvoidCrash.h new file mode 100644 index 0000000..959d035 --- /dev/null +++ b/Ifish/AvoidCrash/AvoidCrash.h @@ -0,0 +1,86 @@ +// +// AvoidCrash.h +// AvoidCrash +// +// Created by mac on 16/9/21. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import +#import + +//category +#import "NSObject+AvoidCrash.h" + +#import "NSArray+AvoidCrash.h" +#import "NSMutableArray+AvoidCrash.h" + +#import "NSDictionary+AvoidCrash.h" +#import "NSMutableDictionary+AvoidCrash.h" + +#import "NSString+AvoidCrash.h" +#import "NSMutableString+AvoidCrash.h" + +#import "NSAttributedString+AvoidCrash.h" +#import "NSMutableAttributedString+AvoidCrash.h" + + +/** + * if you want to get the reason that can cause crash, you can add observer notification in AppDelegate. + * for example: + * + * [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dealwithCrashMessage:) name:AvoidCrashNotification object:nil]; + * + * =========================================================================== + * + * 你如果想要得到导致崩溃的原因,你可以在AppDelegate中监听通知,代码如上。 + * 不管你在哪个线程导致的crash,监听通知的方法都会在主线程中 + * + */ +#define AvoidCrashNotification @"AvoidCrashNotification" + + + +//user can ignore below define +#define AvoidCrashDefaultReturnNil @"This framework default is to return nil to avoid crash." +#define AvoidCrashDefaultIgnore @"This framework default is to ignore this operation to avoid crash." + + +#ifdef DEBUG + +#define AvoidCrashLog(...) NSLog(@"%@",[NSString stringWithFormat:__VA_ARGS__]) + +#else + +#define AvoidCrashLog(...) +#endif + + +@interface AvoidCrash : NSObject + + +/** + * become effective . You can call becomeEffective method in AppDelegate didFinishLaunchingWithOptions + * + * 开始生效.你可以在AppDelegate的didFinishLaunchingWithOptions方法中调用becomeEffective方法 + * + * 这是全局生效,若你只需要部分生效,你可以单个进行处理,比如: + * [NSArray avoidCrashExchangeMethod]; + * [NSMutableArray avoidCrashExchangeMethod]; + * ................. + * ................. + */ ++ (void)becomeEffective; + + +//user can ignore below method <用户可以忽略以下方法> + + ++ (void)exchangeClassMethod:(Class)anClass method1Sel:(SEL)method1Sel method2Sel:(SEL)method2Sel; + ++ (void)exchangeInstanceMethod:(Class)anClass method1Sel:(SEL)method1Sel method2Sel:(SEL)method2Sel; + ++ (void)noteErrorWithException:(NSException *)exception defaultToDo:(NSString *)defaultToDo; + + +@end diff --git a/Ifish/AvoidCrash/AvoidCrash.m b/Ifish/AvoidCrash/AvoidCrash.m new file mode 100644 index 0000000..e020a16 --- /dev/null +++ b/Ifish/AvoidCrash/AvoidCrash.m @@ -0,0 +1,200 @@ +// +// AvoidCrash.m +// AvoidCrash +// +// Created by mac on 16/9/21. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import "AvoidCrash.h" + + +#define AvoidCrashSeparator @"================================================================" +#define AvoidCrashSeparatorWithFlag @"========================AvoidCrash Log==========================" + +#define key_errorName @"errorName" +#define key_errorReason @"errorReason" +#define key_errorPlace @"errorPlace" +#define key_defaultToDo @"defaultToDo" +#define key_callStackSymbols @"callStackSymbols" +#define key_exception @"exception" + + +@implementation AvoidCrash + +/** + * 开始生效(进行方法的交换) + */ ++ (void)becomeEffective { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + + [NSObject avoidCrashExchangeMethod]; + + [NSArray avoidCrashExchangeMethod]; + [NSMutableArray avoidCrashExchangeMethod]; + + [NSDictionary avoidCrashExchangeMethod]; + [NSMutableDictionary avoidCrashExchangeMethod]; + + [NSString avoidCrashExchangeMethod]; + [NSMutableString avoidCrashExchangeMethod]; + + [NSAttributedString avoidCrashExchangeMethod]; + [NSMutableAttributedString avoidCrashExchangeMethod]; + }); +} + +/** + * 类方法的交换 + * + * @param anClass 哪个类 + * @param method1Sel 方法1 + * @param method2Sel 方法2 + */ ++ (void)exchangeClassMethod:(Class)anClass method1Sel:(SEL)method1Sel method2Sel:(SEL)method2Sel { + Method method1 = class_getClassMethod(anClass, method1Sel); + Method method2 = class_getClassMethod(anClass, method2Sel); + method_exchangeImplementations(method1, method2); +} + + +/** + * 对象方法的交换 + * + * @param anClass 哪个类 + * @param method1Sel 方法1(原本的方法) + * @param method2Sel 方法2(要替换成的方法) + */ ++ (void)exchangeInstanceMethod:(Class)anClass method1Sel:(SEL)method1Sel method2Sel:(SEL)method2Sel { + + + Method originalMethod = class_getInstanceMethod(anClass, method1Sel); + Method swizzledMethod = class_getInstanceMethod(anClass, method2Sel); + + BOOL didAddMethod = + class_addMethod(anClass, + method1Sel, + method_getImplementation(swizzledMethod), + method_getTypeEncoding(swizzledMethod)); + + if (didAddMethod) { + class_replaceMethod(anClass, + method2Sel, + method_getImplementation(originalMethod), + method_getTypeEncoding(originalMethod)); + } + + else { + method_exchangeImplementations(originalMethod, swizzledMethod); + } + +} + + + +/** + * 获取堆栈主要崩溃精简化的信息<根据正则表达式匹配出来> + * + * @param callStackSymbolStr 堆栈主要崩溃信息 + * + * @return 堆栈主要崩溃精简化的信息 + */ + ++ (NSString *)getMainCallStackSymbolMessageWithCallStackSymbols:(NSArray *)callStackSymbols { + + //mainCallStackSymbolMsg的格式为 +[类名 方法名] 或者 -[类名 方法名] + __block NSString *mainCallStackSymbolMsg = nil; + + //匹配出来的格式为 +[类名 方法名] 或者 -[类名 方法名] + NSString *regularExpStr = @"[-\\+]\\[.+\\]"; + + + NSRegularExpression *regularExp = [[NSRegularExpression alloc] initWithPattern:regularExpStr options:NSRegularExpressionCaseInsensitive error:nil]; + + + for (int index = 2; index < callStackSymbols.count; index++) { + NSString *callStackSymbol = callStackSymbols[index]; + + [regularExp enumerateMatchesInString:callStackSymbol options:NSMatchingReportProgress range:NSMakeRange(0, callStackSymbol.length) usingBlock:^(NSTextCheckingResult * _Nullable result, NSMatchingFlags flags, BOOL * _Nonnull stop) { + if (result) { + NSString* tempCallStackSymbolMsg = [callStackSymbol substringWithRange:result.range]; + + //get className + NSString *className = [tempCallStackSymbolMsg componentsSeparatedByString:@" "].firstObject; + className = [className componentsSeparatedByString:@"["].lastObject; + + NSBundle *bundle = [NSBundle bundleForClass:NSClassFromString(className)]; + + //filter category and system class + if (![className hasSuffix:@")"] && bundle == [NSBundle mainBundle]) { + mainCallStackSymbolMsg = tempCallStackSymbolMsg; + + } + *stop = YES; + } + }]; + + if (mainCallStackSymbolMsg.length) { + break; + } + } + + return mainCallStackSymbolMsg; +} + + +/** + * 提示崩溃的信息(控制台输出、通知) + * + * @param exception 捕获到的异常 + * @param defaultToDo 这个框架里默认的做法 + */ ++ (void)noteErrorWithException:(NSException *)exception defaultToDo:(NSString *)defaultToDo { + + //堆栈数据 + NSArray *callStackSymbolsArr = [NSThread callStackSymbols]; + + //获取在哪个类的哪个方法中实例化的数组 字符串格式 -[类名 方法名] 或者 +[类名 方法名] + NSString *mainCallStackSymbolMsg = [AvoidCrash getMainCallStackSymbolMessageWithCallStackSymbols:callStackSymbolsArr]; + + if (mainCallStackSymbolMsg == nil) { + + mainCallStackSymbolMsg = @"崩溃方法定位失败,请您查看函数调用栈来排查错误原因"; + + } + + NSString *errorName = exception.name; + NSString *errorReason = exception.reason; + //errorReason 可能为 -[__NSCFConstantString avoidCrashCharacterAtIndex:]: Range or index out of bounds + //将avoidCrash去掉 + errorReason = [errorReason stringByReplacingOccurrencesOfString:@"avoidCrash" withString:@""]; + + NSString *errorPlace = [NSString stringWithFormat:@"Error Place:%@",mainCallStackSymbolMsg]; + + NSString *logErrorMessage = [NSString stringWithFormat:@"\n\n%@\n\n%@\n%@\n%@\n%@\n\n%@\n\n",AvoidCrashSeparatorWithFlag, errorName, errorReason, errorPlace, defaultToDo, AvoidCrashSeparator]; + AvoidCrashLog(@"%@",logErrorMessage); + + //请忽略下面的赋值,目的只是为了能顺利上传cocoapods + logErrorMessage = logErrorMessage; + + NSDictionary *errorInfoDic = @{ + key_errorName : errorName, + key_errorReason : errorReason, + key_errorPlace : errorPlace, + key_defaultToDo : defaultToDo, + key_exception : exception, + key_callStackSymbols : callStackSymbolsArr + }; + + //将错误信息放在字典里,用通知的形式发送出去 + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AvoidCrashNotification object:nil userInfo:errorInfoDic]; + }); + + +} + + +@end diff --git a/Ifish/AvoidCrash/NSArray+AvoidCrash.h b/Ifish/AvoidCrash/NSArray+AvoidCrash.h new file mode 100644 index 0000000..f57e93a --- /dev/null +++ b/Ifish/AvoidCrash/NSArray+AvoidCrash.h @@ -0,0 +1,25 @@ +// +// NSArray+AvoidCrash.h +// AvoidCrash +// +// Created by mac on 16/9/21. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import + +@interface NSArray (AvoidCrash) + ++ (void)avoidCrashExchangeMethod; + +@end + + +/** + * Can avoid crash method + * + * 1. NSArray的快速创建方式 NSArray *array = @[@"chenfanfang", @"AvoidCrash"]; //这种创建方式其实调用的是2中的方法 + * 2. +(instancetype)arrayWithObjects:(const id _Nonnull __unsafe_unretained *)objects count:(NSUInteger)cnt + * 3. - (id)objectAtIndex:(NSUInteger)index + * 4. - (void)getObjects:(__unsafe_unretained id _Nonnull *)objects range:(NSRange)range + */ diff --git a/Ifish/AvoidCrash/NSArray+AvoidCrash.m b/Ifish/AvoidCrash/NSArray+AvoidCrash.m new file mode 100644 index 0000000..6ce49ef --- /dev/null +++ b/Ifish/AvoidCrash/NSArray+AvoidCrash.m @@ -0,0 +1,253 @@ +// +// NSArray+AvoidCrash.m +// AvoidCrash +// +// Created by mac on 16/9/21. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import "NSArray+AvoidCrash.h" + +#import "AvoidCrash.h" + +@implementation NSArray (AvoidCrash) + + ++ (void)avoidCrashExchangeMethod { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + //================= + // class method + //================= + + //instance array method exchange + [AvoidCrash exchangeClassMethod:[self class] method1Sel:@selector(arrayWithObjects:count:) method2Sel:@selector(AvoidCrashArrayWithObjects:count:)]; + + + + //==================== + // instance method + //==================== + + Class __NSArray = NSClassFromString(@"NSArray"); + Class __NSArrayI = NSClassFromString(@"__NSArrayI"); + Class __NSSingleObjectArrayI = NSClassFromString(@"__NSSingleObjectArrayI"); + Class __NSArray0 = NSClassFromString(@"__NSArray0"); + + + //objectsAtIndexes: + [AvoidCrash exchangeInstanceMethod:__NSArray method1Sel:@selector(objectsAtIndexes:) method2Sel:@selector(avoidCrashObjectsAtIndexes:)]; + + + //objectAtIndex: + + [AvoidCrash exchangeInstanceMethod:__NSArrayI method1Sel:@selector(objectAtIndex:) method2Sel:@selector(__NSArrayIAvoidCrashObjectAtIndex:)]; + + [AvoidCrash exchangeInstanceMethod:__NSSingleObjectArrayI method1Sel:@selector(objectAtIndex:) method2Sel:@selector(__NSSingleObjectArrayIAvoidCrashObjectAtIndex:)]; + + [AvoidCrash exchangeInstanceMethod:__NSArray0 method1Sel:@selector(objectAtIndex:) method2Sel:@selector(__NSArray0AvoidCrashObjectAtIndex:)]; + + + //getObjects:range: + [AvoidCrash exchangeInstanceMethod:__NSArray method1Sel:@selector(getObjects:range:) method2Sel:@selector(NSArrayAvoidCrashGetObjects:range:)]; + + [AvoidCrash exchangeInstanceMethod:__NSSingleObjectArrayI method1Sel:@selector(getObjects:range:) method2Sel:@selector(__NSSingleObjectArrayIAvoidCrashGetObjects:range:)]; + + [AvoidCrash exchangeInstanceMethod:__NSArrayI method1Sel:@selector(getObjects:range:) method2Sel:@selector(__NSArrayIAvoidCrashGetObjects:range:)]; + }); + + +} + + +//================================================================= +// instance array +//================================================================= +#pragma mark - instance array + + ++ (instancetype)AvoidCrashArrayWithObjects:(const id _Nonnull __unsafe_unretained *)objects count:(NSUInteger)cnt { + + id instance = nil; + + @try { + instance = [self AvoidCrashArrayWithObjects:objects count:cnt]; + } + @catch (NSException *exception) { + + NSString *defaultToDo = @"This framework default is to remove nil object and instance a array."; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + + //以下是对错误数据的处理,把为nil的数据去掉,然后初始化数组 + NSInteger newObjsIndex = 0; + id _Nonnull __unsafe_unretained newObjects[cnt]; + + for (int i = 0; i < cnt; i++) { + if (objects[i] != nil) { + newObjects[newObjsIndex] = objects[i]; + newObjsIndex++; + } + } + instance = [self AvoidCrashArrayWithObjects:newObjects count:newObjsIndex]; + } + @finally { + return instance; + } +} + + + +//================================================================= +// objectAtIndexedSubscript: +//================================================================= +#pragma mark - objectAtIndexedSubscript: +- (id)avoidCrashObjectAtIndexedSubscript:(NSUInteger)idx { + id object = nil; + + @try { + object = [self avoidCrashObjectAtIndexedSubscript:idx]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + return object; + } + +} + + +//================================================================= +// objectsAtIndexes: +//================================================================= +#pragma mark - objectsAtIndexes: + +- (NSArray *)avoidCrashObjectsAtIndexes:(NSIndexSet *)indexes { + + NSArray *returnArray = nil; + @try { + returnArray = [self avoidCrashObjectsAtIndexes:indexes]; + } @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + + } @finally { + return returnArray; + } +} + + +//================================================================= +// objectAtIndex: +//================================================================= +#pragma mark - objectAtIndex: + +//__NSArrayI objectAtIndex: +- (id)__NSArrayIAvoidCrashObjectAtIndex:(NSUInteger)index { + id object = nil; + + @try { + object = [self __NSArrayIAvoidCrashObjectAtIndex:index]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + return object; + } +} + + + +//__NSSingleObjectArrayI objectAtIndex: +- (id)__NSSingleObjectArrayIAvoidCrashObjectAtIndex:(NSUInteger)index { + id object = nil; + + @try { + object = [self __NSSingleObjectArrayIAvoidCrashObjectAtIndex:index]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + return object; + } +} + +//__NSArray0 objectAtIndex: +- (id)__NSArray0AvoidCrashObjectAtIndex:(NSUInteger)index { + id object = nil; + + @try { + object = [self __NSArray0AvoidCrashObjectAtIndex:index]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + return object; + } +} + + +//================================================================= +// getObjects:range: +//================================================================= +#pragma mark - getObjects:range: + +//NSArray getObjects:range: +- (void)NSArrayAvoidCrashGetObjects:(__unsafe_unretained id _Nonnull *)objects range:(NSRange)range { + + @try { + [self NSArrayAvoidCrashGetObjects:objects range:range]; + } @catch (NSException *exception) { + + NSString *defaultToDo = AvoidCrashDefaultIgnore; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + + } @finally { + + } +} + + +//__NSSingleObjectArrayI getObjects:range: +- (void)__NSSingleObjectArrayIAvoidCrashGetObjects:(__unsafe_unretained id _Nonnull *)objects range:(NSRange)range { + + @try { + [self __NSSingleObjectArrayIAvoidCrashGetObjects:objects range:range]; + } @catch (NSException *exception) { + + NSString *defaultToDo = AvoidCrashDefaultIgnore; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + + } @finally { + + } +} + + +//__NSArrayI getObjects:range: +- (void)__NSArrayIAvoidCrashGetObjects:(__unsafe_unretained id _Nonnull *)objects range:(NSRange)range { + + @try { + [self __NSArrayIAvoidCrashGetObjects:objects range:range]; + } @catch (NSException *exception) { + + NSString *defaultToDo = AvoidCrashDefaultIgnore; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + + } @finally { + + } +} + + + + +@end diff --git a/Ifish/AvoidCrash/NSAttributedString+AvoidCrash.h b/Ifish/AvoidCrash/NSAttributedString+AvoidCrash.h new file mode 100644 index 0000000..6390ed4 --- /dev/null +++ b/Ifish/AvoidCrash/NSAttributedString+AvoidCrash.h @@ -0,0 +1,25 @@ +// +// NSAttributedString+AvoidCrash.h +// AvoidCrashDemo +// +// Created by mac on 16/10/15. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import + +@interface NSAttributedString (AvoidCrash) + ++ (void)avoidCrashExchangeMethod; + +@end + +/** + * Can avoid crash method + * + * 1.- (instancetype)initWithString:(NSString *)str + * 2.- (instancetype)initWithAttributedString:(NSAttributedString *)attrStr + * 3.- (instancetype)initWithString:(NSString *)str attributes:(NSDictionary *)attrs + * + * + */ \ No newline at end of file diff --git a/Ifish/AvoidCrash/NSAttributedString+AvoidCrash.m b/Ifish/AvoidCrash/NSAttributedString+AvoidCrash.m new file mode 100644 index 0000000..4f2d7a4 --- /dev/null +++ b/Ifish/AvoidCrash/NSAttributedString+AvoidCrash.m @@ -0,0 +1,96 @@ +// +// NSAttributedString+AvoidCrash.m +// AvoidCrashDemo +// +// Created by mac on 16/10/15. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import "NSAttributedString+AvoidCrash.h" + +#import "AvoidCrash.h" + +@implementation NSAttributedString (AvoidCrash) + ++ (void)avoidCrashExchangeMethod { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + + Class NSConcreteAttributedString = NSClassFromString(@"NSConcreteAttributedString"); + + //initWithString: + [AvoidCrash exchangeInstanceMethod:NSConcreteAttributedString method1Sel:@selector(initWithString:) method2Sel:@selector(avoidCrashInitWithString:)]; + + //initWithAttributedString + [AvoidCrash exchangeInstanceMethod:NSConcreteAttributedString method1Sel:@selector(initWithAttributedString:) method2Sel:@selector(avoidCrashInitWithAttributedString:)]; + + //initWithString:attributes: + [AvoidCrash exchangeInstanceMethod:NSConcreteAttributedString method1Sel:@selector(initWithString:attributes:) method2Sel:@selector(avoidCrashInitWithString:attributes:)]; + }); + +} + +//================================================================= +// initWithString: +//================================================================= +#pragma mark - initWithString: + +- (instancetype)avoidCrashInitWithString:(NSString *)str { + id object = nil; + + @try { + object = [self avoidCrashInitWithString:str]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + return object; + } +} + + +//================================================================= +// initWithAttributedString +//================================================================= +#pragma mark - initWithAttributedString + +- (instancetype)avoidCrashInitWithAttributedString:(NSAttributedString *)attrStr { + id object = nil; + + @try { + object = [self avoidCrashInitWithAttributedString:attrStr]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + return object; + } +} + + +//================================================================= +// initWithString:attributes: +//================================================================= +#pragma mark - initWithString:attributes: + +- (instancetype)avoidCrashInitWithString:(NSString *)str attributes:(NSDictionary *)attrs { + id object = nil; + + @try { + object = [self avoidCrashInitWithString:str attributes:attrs]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + return object; + } +} + +@end diff --git a/Ifish/AvoidCrash/NSDictionary+AvoidCrash.h b/Ifish/AvoidCrash/NSDictionary+AvoidCrash.h new file mode 100644 index 0000000..1554631 --- /dev/null +++ b/Ifish/AvoidCrash/NSDictionary+AvoidCrash.h @@ -0,0 +1,24 @@ +// +// NSDictionary+AvoidCrash.h +// AvoidCrash +// +// Created by mac on 16/9/21. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import + +@interface NSDictionary (AvoidCrash) + ++ (void)avoidCrashExchangeMethod; + +@end + + +/** + * Can avoid crash method + * + * 1. NSDictionary的快速创建方式 NSDictionary *dict = @{@"frameWork" : @"AvoidCrash"}; //这种创建方式其实调用的是2中的方法 + * 2. +(instancetype)dictionaryWithObjects:(const id _Nonnull __unsafe_unretained *)objects forKeys:(const id _Nonnull __unsafe_unretained *)keys count:(NSUInteger)cnt + * + */ \ No newline at end of file diff --git a/Ifish/AvoidCrash/NSDictionary+AvoidCrash.m b/Ifish/AvoidCrash/NSDictionary+AvoidCrash.m new file mode 100644 index 0000000..0e14762 --- /dev/null +++ b/Ifish/AvoidCrash/NSDictionary+AvoidCrash.m @@ -0,0 +1,56 @@ +// +// NSDictionary+AvoidCrash.m +// AvoidCrash +// +// Created by mac on 16/9/21. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import "NSDictionary+AvoidCrash.h" + +#import "AvoidCrash.h" + +@implementation NSDictionary (AvoidCrash) + ++ (void)avoidCrashExchangeMethod { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + + [AvoidCrash exchangeClassMethod:self method1Sel:@selector(dictionaryWithObjects:forKeys:count:) method2Sel:@selector(avoidCrashDictionaryWithObjects:forKeys:count:)]; + }); +} + + ++ (instancetype)avoidCrashDictionaryWithObjects:(const id _Nonnull __unsafe_unretained *)objects forKeys:(const id _Nonnull __unsafe_unretained *)keys count:(NSUInteger)cnt { + + id instance = nil; + + @try { + instance = [self avoidCrashDictionaryWithObjects:objects forKeys:keys count:cnt]; + } + @catch (NSException *exception) { + + NSString *defaultToDo = @"This framework default is to remove nil key-values and instance a dictionary."; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + + //处理错误的数据,然后重新初始化一个字典 + NSUInteger index = 0; + id _Nonnull __unsafe_unretained newObjects[cnt]; + id _Nonnull __unsafe_unretained newkeys[cnt]; + + for (int i = 0; i < cnt; i++) { + if (objects[i] && keys[i]) { + newObjects[index] = objects[i]; + newkeys[index] = keys[i]; + index++; + } + } + instance = [self avoidCrashDictionaryWithObjects:newObjects forKeys:newkeys count:index]; + } + @finally { + return instance; + } +} + +@end diff --git a/Ifish/AvoidCrash/NSMutableArray+AvoidCrash.h b/Ifish/AvoidCrash/NSMutableArray+AvoidCrash.h new file mode 100644 index 0000000..57addff --- /dev/null +++ b/Ifish/AvoidCrash/NSMutableArray+AvoidCrash.h @@ -0,0 +1,26 @@ +// +// NSMutableArray+AvoidCrash.h +// AvoidCrash +// +// Created by mac on 16/9/21. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import + +@interface NSMutableArray (AvoidCrash) + ++ (void)avoidCrashExchangeMethod; + +@end + + +/** + * Can avoid crash method + * + * 1. - (id)objectAtIndex:(NSUInteger)index + * 2. - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx + * 3. - (void)removeObjectAtIndex:(NSUInteger)index + * 4. - (void)insertObject:(id)anObject atIndex:(NSUInteger)index + * 5. - (void)getObjects:(__unsafe_unretained id _Nonnull *)objects range:(NSRange)range + */ diff --git a/Ifish/AvoidCrash/NSMutableArray+AvoidCrash.m b/Ifish/AvoidCrash/NSMutableArray+AvoidCrash.m new file mode 100644 index 0000000..0397f5a --- /dev/null +++ b/Ifish/AvoidCrash/NSMutableArray+AvoidCrash.m @@ -0,0 +1,143 @@ +// +// NSMutableArray+AvoidCrash.m +// AvoidCrash +// +// Created by mac on 16/9/21. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import "NSMutableArray+AvoidCrash.h" + +#import "AvoidCrash.h" + +@implementation NSMutableArray (AvoidCrash) + ++ (void)avoidCrashExchangeMethod { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + + Class arrayMClass = NSClassFromString(@"__NSArrayM"); + + + //objectAtIndex: + [AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(objectAtIndex:) method2Sel:@selector(avoidCrashObjectAtIndex:)]; + + //setObject:atIndexedSubscript: + [AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(setObject:atIndexedSubscript:) method2Sel:@selector(avoidCrashSetObject:atIndexedSubscript:)]; + + + //removeObjectAtIndex: + [AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(removeObjectAtIndex:) method2Sel:@selector(avoidCrashRemoveObjectAtIndex:)]; + + //insertObject:atIndex: + [AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(insertObject:atIndex:) method2Sel:@selector(avoidCrashInsertObject:atIndex:)]; + + //getObjects:range: + [AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(getObjects:range:) method2Sel:@selector(avoidCrashGetObjects:range:)]; + }); + + + +} + + +//================================================================= +// array set object at index +//================================================================= +#pragma mark - get object from array + + +- (void)avoidCrashSetObject:(id)obj atIndexedSubscript:(NSUInteger)idx { + + @try { + [self avoidCrashSetObject:obj atIndexedSubscript:idx]; + } + @catch (NSException *exception) { + [AvoidCrash noteErrorWithException:exception defaultToDo:AvoidCrashDefaultIgnore]; + } + @finally { + + } +} + + +//================================================================= +// removeObjectAtIndex: +//================================================================= +#pragma mark - removeObjectAtIndex: + +- (void)avoidCrashRemoveObjectAtIndex:(NSUInteger)index { + @try { + [self avoidCrashRemoveObjectAtIndex:index]; + } + @catch (NSException *exception) { + [AvoidCrash noteErrorWithException:exception defaultToDo:AvoidCrashDefaultIgnore]; + } + @finally { + + } +} + + +//================================================================= +// insertObject:atIndex: +//================================================================= +#pragma mark - set方法 +- (void)avoidCrashInsertObject:(id)anObject atIndex:(NSUInteger)index { + @try { + [self avoidCrashInsertObject:anObject atIndex:index]; + } + @catch (NSException *exception) { + [AvoidCrash noteErrorWithException:exception defaultToDo:AvoidCrashDefaultIgnore]; + } + @finally { + + } +} + + +//================================================================= +// objectAtIndex: +//================================================================= +#pragma mark - objectAtIndex: + +- (id)avoidCrashObjectAtIndex:(NSUInteger)index { + id object = nil; + + @try { + object = [self avoidCrashObjectAtIndex:index]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + return object; + } +} + + +//================================================================= +// getObjects:range: +//================================================================= +#pragma mark - getObjects:range: + +- (void)avoidCrashGetObjects:(__unsafe_unretained id _Nonnull *)objects range:(NSRange)range { + + @try { + [self avoidCrashGetObjects:objects range:range]; + } @catch (NSException *exception) { + + NSString *defaultToDo = AvoidCrashDefaultIgnore; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + + } @finally { + + } +} + + + + +@end diff --git a/Ifish/AvoidCrash/NSMutableAttributedString+AvoidCrash.h b/Ifish/AvoidCrash/NSMutableAttributedString+AvoidCrash.h new file mode 100644 index 0000000..58808ac --- /dev/null +++ b/Ifish/AvoidCrash/NSMutableAttributedString+AvoidCrash.h @@ -0,0 +1,23 @@ +// +// NSMutableAttributedString+AvoidCrash.h +// AvoidCrashDemo +// +// Created by mac on 16/10/15. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import + +@interface NSMutableAttributedString (AvoidCrash) + ++ (void)avoidCrashExchangeMethod; + +@end + + +/** + * Can avoid crash method + * + * 1.- (instancetype)initWithString:(NSString *)str + * 2.- (instancetype)initWithString:(NSString *)str attributes:(NSDictionary *)attrs + */ \ No newline at end of file diff --git a/Ifish/AvoidCrash/NSMutableAttributedString+AvoidCrash.m b/Ifish/AvoidCrash/NSMutableAttributedString+AvoidCrash.m new file mode 100644 index 0000000..9db3812 --- /dev/null +++ b/Ifish/AvoidCrash/NSMutableAttributedString+AvoidCrash.m @@ -0,0 +1,74 @@ +// +// NSMutableAttributedString+AvoidCrash.m +// AvoidCrashDemo +// +// Created by mac on 16/10/15. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import "NSMutableAttributedString+AvoidCrash.h" + +#import "AvoidCrash.h" + +@implementation NSMutableAttributedString (AvoidCrash) + ++ (void)avoidCrashExchangeMethod { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + + Class NSConcreteMutableAttributedString = NSClassFromString(@"NSConcreteMutableAttributedString"); + + //initWithString: + [AvoidCrash exchangeInstanceMethod:NSConcreteMutableAttributedString method1Sel:@selector(initWithString:) method2Sel:@selector(avoidCrashInitWithString:)]; + + //initWithString:attributes: + [AvoidCrash exchangeInstanceMethod:NSConcreteMutableAttributedString method1Sel:@selector(initWithString:attributes:) method2Sel:@selector(avoidCrashInitWithString:attributes:)]; + }); +} + +//================================================================= +// initWithString: +//================================================================= +#pragma mark - initWithString: + + +- (instancetype)avoidCrashInitWithString:(NSString *)str { + id object = nil; + + @try { + object = [self avoidCrashInitWithString:str]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + return object; + } +} + + +//================================================================= +// initWithString:attributes: +//================================================================= +#pragma mark - initWithString:attributes: + + +- (instancetype)avoidCrashInitWithString:(NSString *)str attributes:(NSDictionary *)attrs { + id object = nil; + + @try { + object = [self avoidCrashInitWithString:str attributes:attrs]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + return object; + } +} + + +@end diff --git a/Ifish/AvoidCrash/NSMutableDictionary+AvoidCrash.h b/Ifish/AvoidCrash/NSMutableDictionary+AvoidCrash.h new file mode 100644 index 0000000..d691a88 --- /dev/null +++ b/Ifish/AvoidCrash/NSMutableDictionary+AvoidCrash.h @@ -0,0 +1,24 @@ +// +// NSMutableDictionary+AvoidCrash.h +// AvoidCrash +// +// Created by mac on 16/9/22. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import + +@interface NSMutableDictionary (AvoidCrash) + ++ (void)avoidCrashExchangeMethod; + +@end + + +/** + * Can avoid crash method + * + * 1. - (void)setObject:(id)anObject forKey:(id)aKey + * 2. - (void)removeObjectForKey:(id)aKey + * + */ \ No newline at end of file diff --git a/Ifish/AvoidCrash/NSMutableDictionary+AvoidCrash.m b/Ifish/AvoidCrash/NSMutableDictionary+AvoidCrash.m new file mode 100644 index 0000000..9518bde --- /dev/null +++ b/Ifish/AvoidCrash/NSMutableDictionary+AvoidCrash.m @@ -0,0 +1,72 @@ +// +// NSMutableDictionary+AvoidCrash.m +// AvoidCrash +// +// Created by mac on 16/9/22. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import "NSMutableDictionary+AvoidCrash.h" + +#import "AvoidCrash.h" + +@implementation NSMutableDictionary (AvoidCrash) + ++ (void)avoidCrashExchangeMethod { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + Class dictionaryM = NSClassFromString(@"__NSDictionaryM"); + + //setObject:forKey: + [AvoidCrash exchangeInstanceMethod:dictionaryM method1Sel:@selector(setObject:forKey:) method2Sel:@selector(avoidCrashSetObject:forKey:)]; + + + //removeObjectForKey: + Method removeObjectForKey = class_getInstanceMethod(dictionaryM, @selector(removeObjectForKey:)); + Method avoidCrashRemoveObjectForKey = class_getInstanceMethod(dictionaryM, @selector(avoidCrashRemoveObjectForKey:)); + method_exchangeImplementations(removeObjectForKey, avoidCrashRemoveObjectForKey); + }); +} + + +//================================================================= +// setObject:forKey: +//================================================================= +#pragma mark - setObject:forKey: + +- (void)avoidCrashSetObject:(id)anObject forKey:(id)aKey { + + @try { + [self avoidCrashSetObject:anObject forKey:aKey]; + } + @catch (NSException *exception) { + [AvoidCrash noteErrorWithException:exception defaultToDo:AvoidCrashDefaultIgnore]; + } + @finally { + + } +} + +//================================================================= +// removeObjectForKey: +//================================================================= +#pragma mark - removeObjectForKey: + +- (void)avoidCrashRemoveObjectForKey:(id)aKey { + + @try { + [self avoidCrashRemoveObjectForKey:aKey]; + } + @catch (NSException *exception) { + [AvoidCrash noteErrorWithException:exception defaultToDo:AvoidCrashDefaultIgnore]; + } + @finally { + + } +} + + + + +@end diff --git a/Ifish/AvoidCrash/NSMutableString+AvoidCrash.h b/Ifish/AvoidCrash/NSMutableString+AvoidCrash.h new file mode 100644 index 0000000..3826299 --- /dev/null +++ b/Ifish/AvoidCrash/NSMutableString+AvoidCrash.h @@ -0,0 +1,29 @@ +// +// NSMutableString+AvoidCrash.h +// AvoidCrashDemo +// +// Created by mac on 16/10/6. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import + +@interface NSMutableString (AvoidCrash) + ++ (void)avoidCrashExchangeMethod; + +@end + + +/** + * Can avoid crash method + * + * 1. 由于NSMutableString是继承于NSString,所以这里和NSString有些同样的方法就不重复写了 + * 2. - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)aString + * 3. - (void)insertString:(NSString *)aString atIndex:(NSUInteger)loc + * 4. - (void)deleteCharactersInRange:(NSRange)range + * + */ + + + diff --git a/Ifish/AvoidCrash/NSMutableString+AvoidCrash.m b/Ifish/AvoidCrash/NSMutableString+AvoidCrash.m new file mode 100644 index 0000000..61dd57d --- /dev/null +++ b/Ifish/AvoidCrash/NSMutableString+AvoidCrash.m @@ -0,0 +1,97 @@ +// +// NSMutableString+AvoidCrash.m +// AvoidCrashDemo +// +// Created by mac on 16/10/6. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import "NSMutableString+AvoidCrash.h" + +#import "AvoidCrash.h" + +@implementation NSMutableString (AvoidCrash) + ++ (void)avoidCrashExchangeMethod { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + + Class stringClass = NSClassFromString(@"__NSCFString"); + + //replaceCharactersInRange + [AvoidCrash exchangeInstanceMethod:stringClass method1Sel:@selector(replaceCharactersInRange:withString:) method2Sel:@selector(avoidCrashReplaceCharactersInRange:withString:)]; + + //insertString:atIndex: + [AvoidCrash exchangeInstanceMethod:stringClass method1Sel:@selector(insertString:atIndex:) method2Sel:@selector(avoidCrashInsertString:atIndex:)]; + + //deleteCharactersInRange + [AvoidCrash exchangeInstanceMethod:stringClass method1Sel:@selector(deleteCharactersInRange:) method2Sel:@selector(avoidCrashDeleteCharactersInRange:)]; + }); +} + +//================================================================= +// replaceCharactersInRange +//================================================================= +#pragma mark - replaceCharactersInRange + +- (void)avoidCrashReplaceCharactersInRange:(NSRange)range withString:(NSString *)aString { + + @try { + [self avoidCrashReplaceCharactersInRange:range withString:aString]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultIgnore; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + + } +} + +//================================================================= +// insertString:atIndex: +//================================================================= +#pragma mark - insertString:atIndex: + +- (void)avoidCrashInsertString:(NSString *)aString atIndex:(NSUInteger)loc { + + @try { + [self avoidCrashInsertString:aString atIndex:loc]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultIgnore; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + + } +} + +//================================================================= +// deleteCharactersInRange +//================================================================= +#pragma mark - deleteCharactersInRange + +- (void)avoidCrashDeleteCharactersInRange:(NSRange)range { + + @try { + [self avoidCrashDeleteCharactersInRange:range]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultIgnore; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + + } +} + + + + + + + + +@end diff --git a/Ifish/AvoidCrash/NSObject+AvoidCrash.h b/Ifish/AvoidCrash/NSObject+AvoidCrash.h new file mode 100644 index 0000000..01de329 --- /dev/null +++ b/Ifish/AvoidCrash/NSObject+AvoidCrash.h @@ -0,0 +1,25 @@ +// +// NSObject+AvoidCrash.h +// AvoidCrashDemo +// +// Created by mac on 16/10/11. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import + +@interface NSObject (AvoidCrash) + ++ (void)avoidCrashExchangeMethod; + +@end + +/** + * Can avoid crash method + * + * 1.- (void)setValue:(id)value forKey:(NSString *)key + * 2.- (void)setValue:(id)value forKeyPath:(NSString *)keyPath + * 3.- (void)setValue:(id)value forUndefinedKey:(NSString *)key //这个方法一般用来重写,不会主动调用 + * 4.- (void)setValuesForKeysWithDictionary:(NSDictionary *)keyedValues + * + */ \ No newline at end of file diff --git a/Ifish/AvoidCrash/NSObject+AvoidCrash.m b/Ifish/AvoidCrash/NSObject+AvoidCrash.m new file mode 100644 index 0000000..0513a49 --- /dev/null +++ b/Ifish/AvoidCrash/NSObject+AvoidCrash.m @@ -0,0 +1,114 @@ +// +// NSObject+AvoidCrash.m +// AvoidCrashDemo +// +// Created by mac on 16/10/11. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import "NSObject+AvoidCrash.h" + +#import "AvoidCrash.h" + +@implementation NSObject (AvoidCrash) + ++ (void)avoidCrashExchangeMethod { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + //setValue:forKey: + [AvoidCrash exchangeInstanceMethod:[self class] method1Sel:@selector(setValue:forKey:) method2Sel:@selector(avoidCrashSetValue:forKey:)]; + + //setValue:forKeyPath: + [AvoidCrash exchangeInstanceMethod:[self class] method1Sel:@selector(setValue:forKeyPath:) method2Sel:@selector(avoidCrashSetValue:forKeyPath:)]; + + //setValue:forUndefinedKey: + [AvoidCrash exchangeInstanceMethod:[self class] method1Sel:@selector(setValue:forUndefinedKey:) method2Sel:@selector(avoidCrashSetValue:forUndefinedKey:)]; + + //setValuesForKeysWithDictionary: + [AvoidCrash exchangeInstanceMethod:[self class] method1Sel:@selector(setValuesForKeysWithDictionary:) method2Sel:@selector(avoidCrashSetValuesForKeysWithDictionary:)]; + }); + + +} + + + +//================================================================= +// setValue:forKey: +//================================================================= +#pragma mark - setValue:forKey: + +- (void)avoidCrashSetValue:(id)value forKey:(NSString *)key { + @try { + [self avoidCrashSetValue:value forKey:key]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultIgnore; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + + } +} + + +//================================================================= +// setValue:forKeyPath: +//================================================================= +#pragma mark - setValue:forKeyPath: + +- (void)avoidCrashSetValue:(id)value forKeyPath:(NSString *)keyPath { + @try { + [self avoidCrashSetValue:value forKeyPath:keyPath]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultIgnore; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + + } +} + + + +//================================================================= +// setValue:forUndefinedKey: +//================================================================= +#pragma mark - setValue:forUndefinedKey: + +- (void)avoidCrashSetValue:(id)value forUndefinedKey:(NSString *)key { + @try { + [self avoidCrashSetValue:value forUndefinedKey:key]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultIgnore; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + + } +} + + +//================================================================= +// setValuesForKeysWithDictionary: +//================================================================= +#pragma mark - setValuesForKeysWithDictionary: + +- (void)avoidCrashSetValuesForKeysWithDictionary:(NSDictionary *)keyedValues { + @try { + [self avoidCrashSetValuesForKeysWithDictionary:keyedValues]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultIgnore; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + + } +} + + +@end diff --git a/Ifish/AvoidCrash/NSString+AvoidCrash.h b/Ifish/AvoidCrash/NSString+AvoidCrash.h new file mode 100644 index 0000000..a8d17a7 --- /dev/null +++ b/Ifish/AvoidCrash/NSString+AvoidCrash.h @@ -0,0 +1,29 @@ +// +// NSString+AvoidCrash.h +// AvoidCrashDemo +// +// Created by mac on 16/10/5. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import + +@interface NSString (AvoidCrash) + ++ (void)avoidCrashExchangeMethod; + +@end + + +/** + * Can avoid crash method + * + * 1. - (unichar)characterAtIndex:(NSUInteger)index + * 2. - (NSString *)substringFromIndex:(NSUInteger)from + * 3. - (NSString *)substringToIndex:(NSUInteger)to { + * 4. - (NSString *)substringWithRange:(NSRange)range { + * 5. - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement + * 6. - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement options:(NSStringCompareOptions)options range:(NSRange)searchRange + * 7. - (NSString *)stringByReplacingCharactersInRange:(NSRange)range withString:(NSString *)replacement + * + */ \ No newline at end of file diff --git a/Ifish/AvoidCrash/NSString+AvoidCrash.m b/Ifish/AvoidCrash/NSString+AvoidCrash.m new file mode 100644 index 0000000..e7196c7 --- /dev/null +++ b/Ifish/AvoidCrash/NSString+AvoidCrash.m @@ -0,0 +1,204 @@ +// +// NSString+AvoidCrash.m +// AvoidCrashDemo +// +// Created by mac on 16/10/5. +// Copyright © 2016年 chenfanfang. All rights reserved. +// + +#import "NSString+AvoidCrash.h" + +#import "AvoidCrash.h" + +@implementation NSString (AvoidCrash) + ++ (void)avoidCrashExchangeMethod { + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + Class stringClass = NSClassFromString(@"__NSCFConstantString"); + + //characterAtIndex + [AvoidCrash exchangeInstanceMethod:stringClass method1Sel:@selector(characterAtIndex:) method2Sel:@selector(avoidCrashCharacterAtIndex:)]; + + //substringFromIndex + [AvoidCrash exchangeInstanceMethod:stringClass method1Sel:@selector(substringFromIndex:) method2Sel:@selector(avoidCrashSubstringFromIndex:)]; + + //substringToIndex + [AvoidCrash exchangeInstanceMethod:stringClass method1Sel:@selector(substringToIndex:) method2Sel:@selector(avoidCrashSubstringToIndex:)]; + + //substringWithRange: + [AvoidCrash exchangeInstanceMethod:stringClass method1Sel:@selector(substringWithRange:) method2Sel:@selector(avoidCrashSubstringWithRange:)]; + + //stringByReplacingOccurrencesOfString: + [AvoidCrash exchangeInstanceMethod:stringClass method1Sel:@selector(stringByReplacingOccurrencesOfString:withString:) method2Sel:@selector(avoidCrashStringByReplacingOccurrencesOfString:withString:)]; + + //stringByReplacingOccurrencesOfString:withString:options:range: + [AvoidCrash exchangeInstanceMethod:stringClass method1Sel:@selector(stringByReplacingOccurrencesOfString:withString:options:range:) method2Sel:@selector(avoidCrashStringByReplacingOccurrencesOfString:withString:options:range:)]; + + //stringByReplacingCharactersInRange:withString: + [AvoidCrash exchangeInstanceMethod:stringClass method1Sel:@selector(stringByReplacingCharactersInRange:withString:) method2Sel:@selector(avoidCrashStringByReplacingCharactersInRange:withString:)]; + }); + +} + + +//================================================================= +// characterAtIndex: +//================================================================= +#pragma mark - characterAtIndex: + +- (unichar)avoidCrashCharacterAtIndex:(NSUInteger)index { + + unichar characteristic; + @try { + characteristic = [self avoidCrashCharacterAtIndex:index]; + } + @catch (NSException *exception) { + + NSString *defaultToDo = @"This framework default is to return a without assign unichar."; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + } + @finally { + return characteristic; + } +} + +//================================================================= +// substringFromIndex: +//================================================================= +#pragma mark - substringFromIndex: + +- (NSString *)avoidCrashSubstringFromIndex:(NSUInteger)from { + + NSString *subString = nil; + + @try { + subString = [self avoidCrashSubstringFromIndex:from]; + } + @catch (NSException *exception) { + + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + subString = nil; + } + @finally { + return subString; + } +} + +//================================================================= +// substringToIndex +//================================================================= +#pragma mark - substringToIndex + +- (NSString *)avoidCrashSubstringToIndex:(NSUInteger)to { + + NSString *subString = nil; + + @try { + subString = [self avoidCrashSubstringToIndex:to]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + subString = nil; + } + @finally { + return subString; + } +} + + +//================================================================= +// substringWithRange: +//================================================================= +#pragma mark - substringWithRange: + +- (NSString *)avoidCrashSubstringWithRange:(NSRange)range { + + NSString *subString = nil; + + @try { + subString = [self avoidCrashSubstringWithRange:range]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + subString = nil; + } + @finally { + return subString; + } +} + +//================================================================= +// stringByReplacingOccurrencesOfString: +//================================================================= +#pragma mark - stringByReplacingOccurrencesOfString: + +- (NSString *)avoidCrashStringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement { + + NSString *newStr = nil; + + @try { + newStr = [self avoidCrashStringByReplacingOccurrencesOfString:target withString:replacement]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + newStr = nil; + } + @finally { + return newStr; + } +} + +//================================================================= +// stringByReplacingOccurrencesOfString:withString:options:range: +//================================================================= +#pragma mark - stringByReplacingOccurrencesOfString:withString:options:range: + +- (NSString *)avoidCrashStringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement options:(NSStringCompareOptions)options range:(NSRange)searchRange { + + NSString *newStr = nil; + + @try { + newStr = [self avoidCrashStringByReplacingOccurrencesOfString:target withString:replacement options:options range:searchRange]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + newStr = nil; + } + @finally { + return newStr; + } +} + + +//================================================================= +// stringByReplacingCharactersInRange:withString: +//================================================================= +#pragma mark - stringByReplacingCharactersInRange:withString: + +- (NSString *)avoidCrashStringByReplacingCharactersInRange:(NSRange)range withString:(NSString *)replacement { + + + NSString *newStr = nil; + + @try { + newStr = [self avoidCrashStringByReplacingCharactersInRange:range withString:replacement]; + } + @catch (NSException *exception) { + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + newStr = nil; + } + @finally { + return newStr; + } +} + + +@end diff --git a/Ifish/Info.plist b/Ifish/Info.plist index 0ac08f2..709a8d9 100644 --- a/Ifish/Info.plist +++ b/Ifish/Info.plist @@ -70,7 +70,7 @@ CFBundleVersion - $(CURRENT_PROJECT_VERSION) + 4 ITSAppUsesNonExemptEncryption LSApplicationCategoryType @@ -407,6 +407,8 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIUserInterfaceStyle + Light UIViewControllerBasedStatusBarAppearance diff --git a/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.m b/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.m index 737af1a..e7192c8 100644 --- a/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.m +++ b/Ifish/controllers/ConnectAauariumVC/ConAquarChooseWiFiVC.m @@ -50,6 +50,10 @@ Assign BOOL isGoChangeWiFi;//更换为设备的WiFi if (!_topImage) { _topImage = InitObject(UIImageView); [_topImage setImage:IMAGEBYENAME(@"icons_con_topbg")]; + if (self.deviceType==DEVICECAMERA) + { + [_topImage setImage:IMAGEBYENAME(@"apcoonetc")]; + } } return _topImage; } @@ -74,7 +78,7 @@ Assign BOOL isGoChangeWiFi;//更换为设备的WiFi if (self.deviceType==DEVICECAMERA) { - tip1=@"1.请长按摄像头背后复位孔,复位摄像头,复位后15秒内断电通电3次进入热点模式;"; + tip1=@"1.请长按摄像头背后复位孔,复位摄像头,进入热点模式"; tip2=@"2.点击去设置:设置-WiFi-选择GW-AP-xxx的网络,一般无密码或12345678或查看说明书,连接好后返回爱奇鱼app。"; } NSArray*textArr=@[tip1,tip2]; diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm index be48e9a..3a54ae1 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm @@ -644,6 +644,7 @@ self.attentionLabel.text=@"1、请长按摄像头背后复位孔,复位摄像 self.sBtn.hidden = YES; self.nodImg.hidden = YES; self.redTipLable.hidden=YES; + self.attentionLabel.hidden=YES; } -(void)wifiviewkeyboardWillHide:(NSNotification *)notify{