-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
李杰
committed
Nov 11, 2018
1 parent
d89d2e4
commit eaff9d3
Showing
11 changed files
with
134 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2.42 KB
(100%)
....xcodeproj/project.xcworkspace/xcuserdata/jezz.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// NSMutableSet+MutableSetHook.h | ||
// JJException | ||
// | ||
// Created by Jezz on 2018/11/11. | ||
// Copyright © 2018年 Jezz. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface NSMutableSet (MutableSetHook) | ||
|
||
+ (void)jj_swizzleNSMutableSet; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// NSMutableSet+MutableSetHook.m | ||
// JJException | ||
// | ||
// Created by Jezz on 2018/11/11. | ||
// Copyright © 2018年 Jezz. All rights reserved. | ||
// | ||
|
||
#import "NSMutableSet+MutableSetHook.h" | ||
#import "NSObject+SwizzleHook.h" | ||
#import <objc/runtime.h> | ||
#import "JJExceptionProxy.h" | ||
|
||
@implementation NSMutableSet (MutableSetHook) | ||
|
||
+ (void)jj_swizzleNSMutableSet{ | ||
NSMutableSet* instanceObject = [NSMutableSet new]; | ||
Class cls = object_getClass(instanceObject); | ||
|
||
swizzleInstanceMethod(cls,@selector(addObject:), @selector(hookAddObject:)); | ||
swizzleInstanceMethod(cls,@selector(removeObject:), @selector(hookRemoveObject:)); | ||
} | ||
|
||
- (void) hookAddObject:(id)object { | ||
if (object) { | ||
[self hookAddObject:object]; | ||
} else { | ||
handleCrashException(JJExceptionGuardArrayContainer,@"NSSet addObject nil object"); | ||
} | ||
} | ||
|
||
- (void) hookRemoveObject:(id)object { | ||
if (object) { | ||
[self hookRemoveObject:object]; | ||
} else { | ||
handleCrashException(JJExceptionGuardArrayContainer,@"NSSet removeObject nil object"); | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// NSSet+SetHook.h | ||
// JJException | ||
// | ||
// Created by Jezz on 2018/11/11. | ||
// Copyright © 2018年 Jezz. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface NSSet (SetHook) | ||
|
||
+ (void)jj_swizzleNSSet; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// NSSet+SetHook.m | ||
// JJException | ||
// | ||
// Created by Jezz on 2018/11/11. | ||
// Copyright © 2018年 Jezz. All rights reserved. | ||
// | ||
|
||
#import "NSSet+SetHook.h" | ||
#import "NSObject+SwizzleHook.h" | ||
#import "JJExceptionProxy.h" | ||
|
||
@implementation NSSet (SetHook) | ||
|
||
+ (void)jj_swizzleNSSet{ | ||
[NSSet jj_swizzleClassMethod:@selector(setWithObject:) withSwizzleMethod:@selector(hookSetWithObject:)]; | ||
} | ||
|
||
+ (instancetype)hookSetWithObject:(id)object{ | ||
if (object){ | ||
return [self hookSetWithObject:object]; | ||
} | ||
handleCrashException(JJExceptionGuardArrayContainer,@"NSSet setWithObject nil object"); | ||
return nil; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters