From 28e53a7dc5b41d29055736822602b147282b33c0 Mon Sep 17 00:00:00 2001 From: sunjianqin Date: Wed, 12 Sep 2018 14:15:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0replaceCharactersInRange:with?= =?UTF-8?q?String:=E7=9A=84=E5=B4=A9=E6=BA=83=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NSMutableAttributedString+AvoidCrash.m | 24 +++++++++++++++++++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++++++ 2 files changed, 32 insertions(+) create mode 100644 AvoidCrashDemo/AvoidCrashDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/AvoidCrash/NSMutableAttributedString+AvoidCrash.m b/AvoidCrash/NSMutableAttributedString+AvoidCrash.m index dbfc103..8b043d3 100644 --- a/AvoidCrash/NSMutableAttributedString+AvoidCrash.m +++ b/AvoidCrash/NSMutableAttributedString+AvoidCrash.m @@ -24,6 +24,9 @@ + (void)avoidCrashExchangeMethod { //initWithString:attributes: [AvoidCrash exchangeInstanceMethod:NSConcreteMutableAttributedString method1Sel:@selector(initWithString:attributes:) method2Sel:@selector(avoidCrashInitWithString:attributes:)]; + + //replaceCharactersInRange:withString: + [AvoidCrash exchangeInstanceMethod:NSConcreteMutableAttributedString method1Sel:@selector(replaceCharactersInRange:withString:) method2Sel:@selector(avoidCrashReplaceCharactersInRange:withString:)]; }); } @@ -71,4 +74,25 @@ - (instancetype)avoidCrashInitWithString:(NSString *)str attributes:(NSDictionar } +//================================================================= +// replaceCharactersInRange:withString: +//================================================================= +#pragma mark - replaceCharactersInRange:withString: + + +- (void)avoidCrashReplaceCharactersInRange:(NSRange)range withString:(NSString *)aString { + + @try { + [self avoidCrashReplaceCharactersInRange:range withString:aString]; + } @catch (NSException *exception) { + + NSString *defaultToDo = AvoidCrashDefaultReturnNil; + [AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo]; + + } @finally { + + } +} + + @end diff --git a/AvoidCrashDemo/AvoidCrashDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/AvoidCrashDemo/AvoidCrashDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/AvoidCrashDemo/AvoidCrashDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + +