-
Notifications
You must be signed in to change notification settings - Fork 0
/
ANSSwizzler.h
52 lines (41 loc) · 1.25 KB
/
ANSSwizzler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// ANSSwizzler.h
// AnalysysAgent
//
// Created by analysys on 2018/2/6.
// Copyright © 2018年 analysys. All rights reserved.
//
#import <Foundation/Foundation.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wstrict-prototypes"
typedef void (^swizzleBlock)();
#pragma clang diagnostic pop
@interface ANSSwizzler : NSObject
/**
hook方法
@param aSelector sel
@param aClass class
@param aBlock 回调函数
@param aName hook标识
*/
+ (void)swizzleSelector:(SEL)aSelector onClass:(Class)aClass withBlock:(swizzleBlock)aBlock named:(NSString *)aName;
/**
取消hook
@param aSelector sel
@param aClass class
@param aName hook标识
*/
+ (void)unswizzleSelector:(SEL)aSelector onClass:(Class)aClass named:(NSString *)aName;
@end
@interface ANSSwizzle : NSObject
@property (nonatomic, assign) Class class;
@property (nonatomic, assign) SEL selector;
@property (nonatomic, assign) IMP originalMethod;
@property (nonatomic, assign) uint numArgs;
@property (nonatomic, copy) NSMapTable *blocks;
- (instancetype)initWithBlock:(swizzleBlock)aBlock
named:(NSString *)aName
forClass:(Class)aClass
selector:(SEL)aSelector
originalMethod:(IMP)aMethod;
@end