-
Notifications
You must be signed in to change notification settings - Fork 3
/
MCCSwizzle.h
40 lines (31 loc) · 1.47 KB
/
MCCSwizzle.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
//
// MCCSwizzle.h
// MailCommonCode
//
// Created by Scott Little on 24/11/2011.
// Copyright (c) 2011 Little Known Software. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <objc/message.h>
#include "MCCCommonHeader.h"
typedef enum MCC_PREFIXED_NAME(SwizzleType) {
MCC_PREFIXED_NAME(SwizzleTypeNone),
MCC_PREFIXED_NAME(SwizzleTypeNormal),
MCC_PREFIXED_NAME(SwizzleTypeAdd)
} MCC_PREFIXED_NAME(SwizzleType);
typedef MCC_PREFIXED_NAME(SwizzleType)(^MCC_PREFIXED_NAME(SwizzleFilterBlock))(NSString *methodName);
// rename class to avoid conflicts
@interface MCC_PREFIXED_NAME(Swizzle) : NSObject
+ (void)swizzle;
+ (void)swizzleToClass:(Class)targetClass;
+ (void)swizzleWithMethodsPassingTest:(MCC_PREFIXED_NAME(SwizzleFilterBlock))testBlock;
+ (Class)makeSubclassOf:(Class)baseClass;
+ (void)addAllMethodsToClass:(Class)targetClass usingPrefix:(NSString*)prefix;
+ (void)addMethodsPassingTest:(MCC_PREFIXED_NAME(SwizzleFilterBlock))testBlock toClass:(Class)targetClass usingPrefix:(NSString*)prefix withDebugging:(BOOL)debugging;
@end
@interface MCC_PREFIXED_NAME(Swizzle) (Properties)
+ (void)swizzlePropertiesToClass:(Class)targetClass;
@end
// Macros to call the super of a method normally
#define SUPER_SELECTOR(selName,...) objc_msgSendSuper(&(struct objc_super){self, class_getSuperclass([self class])}, @selector(selName) , ##__VA_ARGS__)
#define SUPER(...) objc_msgSendSuper(&(struct objc_super){self, class_getSuperclass([self class])},_cmd, ##__VA_ARGS__)