Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions SafeObject.podspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Pod::Spec.new do |s|
s.name = 'SafeObject'
s.version = '0.0.1'
s.authors = { 'daniulaolu' => '287929070@qq.com' }
s.homepage = 'https://github.com/MrLujh/SafeObject'
s.name = 'SafeObject_zp'
s.version = '0.1.1'
s.authors = { 'ZPP506' => '94460330@qq.com' }
s.homepage = 'https://github.com/ZPP506/SafeObject'
s.summary = '项目中防止数组字典崩溃'
s.source = { :git => 'https://github.com/MrLujh/SafeObject.git',
s.source = { :git => 'https://github.com/ZPP506/SafeObject.git',
:tag => s.version.to_s }
s.license = { :type => "MIT", :file => "LICENSE" }
s.platform = :ios, '7.0'
s.requires_arc = true
s.source_files = "SafeObject", "*.{h,m}"
s.source_files = "SafeObject_zp", "*.{h,m}"
s.ios.deployment_target = '7.0'
end
16 changes: 14 additions & 2 deletions SafeObjectCrash.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
2E14AA3D208722DD009878C7 /* NSObject+Swizzling.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E14AA36208722DC009878C7 /* NSObject+Swizzling.m */; };
2E14AA3E208722DD009878C7 /* NSArray+Safe.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E14AA37208722DC009878C7 /* NSArray+Safe.m */; };
2E14AA3F208722DD009878C7 /* NSObject+ImpChangeTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E14AA38208722DC009878C7 /* NSObject+ImpChangeTool.m */; };
848FED29225DE3C700938C39 /* NSAttributedString+zp_Safe.m in Sources */ = {isa = PBXBuildFile; fileRef = 848FED28225DE3C700938C39 /* NSAttributedString+zp_Safe.m */; };
848FED2C225DE3E100938C39 /* NSMutableAttributedString+zp_Safe.m in Sources */ = {isa = PBXBuildFile; fileRef = 848FED2B225DE3E100938C39 /* NSMutableAttributedString+zp_Safe.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -48,6 +50,10 @@
2E14AA36208722DC009878C7 /* NSObject+Swizzling.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+Swizzling.m"; sourceTree = "<group>"; };
2E14AA37208722DC009878C7 /* NSArray+Safe.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+Safe.m"; sourceTree = "<group>"; };
2E14AA38208722DC009878C7 /* NSObject+ImpChangeTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+ImpChangeTool.m"; sourceTree = "<group>"; };
848FED27225DE3C700938C39 /* NSAttributedString+zp_Safe.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSAttributedString+zp_Safe.h"; sourceTree = "<group>"; };
848FED28225DE3C700938C39 /* NSAttributedString+zp_Safe.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSAttributedString+zp_Safe.m"; sourceTree = "<group>"; };
848FED2A225DE3E100938C39 /* NSMutableAttributedString+zp_Safe.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSMutableAttributedString+zp_Safe.h"; sourceTree = "<group>"; };
848FED2B225DE3E100938C39 /* NSMutableAttributedString+zp_Safe.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSMutableAttributedString+zp_Safe.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -112,6 +118,10 @@
2E14AA38208722DC009878C7 /* NSObject+ImpChangeTool.m */,
2E14AA31208722DC009878C7 /* NSObject+Swizzling.h */,
2E14AA36208722DC009878C7 /* NSObject+Swizzling.m */,
848FED27225DE3C700938C39 /* NSAttributedString+zp_Safe.h */,
848FED28225DE3C700938C39 /* NSAttributedString+zp_Safe.m */,
848FED2A225DE3E100938C39 /* NSMutableAttributedString+zp_Safe.h */,
848FED2B225DE3E100938C39 /* NSMutableAttributedString+zp_Safe.m */,
);
path = SafeObject;
sourceTree = SOURCE_ROOT;
Expand Down Expand Up @@ -187,7 +197,9 @@
buildActionMask = 2147483647;
files = (
2E14AA39208722DD009878C7 /* NSMutableArray+Safe.m in Sources */,
848FED29225DE3C700938C39 /* NSAttributedString+zp_Safe.m in Sources */,
2E14A9CD208717BF009878C7 /* ViewController.m in Sources */,
848FED2C225DE3E100938C39 /* NSMutableAttributedString+zp_Safe.m in Sources */,
2E14AA3E208722DD009878C7 /* NSArray+Safe.m in Sources */,
2E14A9D8208717C0009878C7 /* main.m in Sources */,
2E14AA3F208722DD009878C7 /* NSObject+ImpChangeTool.m in Sources */,
Expand Down Expand Up @@ -336,7 +348,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 9M422A22FH;
DEVELOPMENT_TEAM = 423Z88A982;
INFOPLIST_FILE = SafeObjectCrash/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -353,7 +365,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 9M422A22FH;
DEVELOPMENT_TEAM = 423Z88A982;
INFOPLIST_FILE = SafeObjectCrash/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions SafeObject_zp/NSAttributedString+zp_Safe.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// NSAttributedString+zp_Safe.h
// SafeObjectCrash
//
// Created by admin on 2019/4/10.
// Copyright © 2019 lujh. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSAttributedString (zp_Safe)

@end

NS_ASSUME_NONNULL_END
33 changes: 33 additions & 0 deletions SafeObject_zp/NSAttributedString+zp_Safe.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// NSAttributedString+zp_Safe.m
// SafeObjectCrash
//
// Created by admin on 2019/4/10.
// Copyright © 2019 lujh. All rights reserved.
//

#import "NSAttributedString+zp_Safe.h"
#import <objc/runtime.h>

@implementation NSAttributedString (zp_Safe)
+ (void)load{

Method oldMethod = class_getInstanceMethod(self, @selector(initWithString:attributes:));
Method safeMethod = class_getInstanceMethod(self, @selector(safe_initWithString:attributes:));

method_exchangeImplementations(oldMethod, safeMethod);


}
- (instancetype)safe_initWithString:(NSString *)str attributes:(NSDictionary<NSAttributedStringKey,id> *)attrs{
if (str.length <= 0) {
#ifdef DEBUG
NSAssert(str, @"Method (initWithString:attributes:) invlie:str");
#else
str = @"";
#endif

}
return [self safe_initWithString:str attributes:attrs];
}
@end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions SafeObject_zp/NSMutableAttributedString+zp_Safe.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// NSMutableAttributedString+zp_Safe.h
// SafeObjectCrash
//
// Created by admin on 2019/4/10.
// Copyright © 2019 lujh. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSMutableAttributedString (zp_Safe)

@end

NS_ASSUME_NONNULL_END
33 changes: 33 additions & 0 deletions SafeObject_zp/NSMutableAttributedString+zp_Safe.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// NSMutableAttributedString+zp_Safe.m
// SafeObjectCrash
//
// Created by admin on 2019/4/10.
// Copyright © 2019 lujh. All rights reserved.
//

#import "NSMutableAttributedString+zp_Safe.h"
#import <objc/runtime.h>

@implementation NSMutableAttributedString (zp_Safe)
+ (void)load{

Method oldMethod = class_getInstanceMethod(self, @selector(initWithString:attributes:));
Method safeMethod = class_getInstanceMethod(self, @selector(safe_initWithString:attributes:));

method_exchangeImplementations(oldMethod, safeMethod);


}
- (instancetype)safe_initWithString:(NSString *)str attributes:(NSDictionary<NSAttributedStringKey,id> *)attrs{
if (str.length <= 0) {
#ifdef DEBUG
NSAssert(str, @"Method (initWithString:attributes:) invlie:str");
#else
str = @"";
#endif

}
return [self safe_initWithString:str attributes:attrs];
}
@end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.