Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/*
2
 * Copyright 2018 Google LLC
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17
#import <Foundation/Foundation.h>
18
 
19
NS_ASSUME_NONNULL_BEGIN
20
 
21
/** This class handles the runtime manipulation necessary to instrument selectors. It stores the
22
 *  classes and selectors that have been swizzled, and runs all operations on its own queue.
23
 */
24
@interface GULSwizzler : NSObject
25
 
26
/** Manipulates the Objective-C runtime to replace the original IMP with the supplied block.
27
 *
28
 *  @param aClass The class to swizzle.
29
 *  @param selector The selector of the class to swizzle.
30
 *  @param isClassSelector A BOOL specifying whether the selector is a class or instance selector.
31
 *  @param block The block that replaces the original IMP.
32
 */
33
+ (void)swizzleClass:(Class)aClass
34
            selector:(SEL)selector
35
     isClassSelector:(BOOL)isClassSelector
36
           withBlock:(nullable id)block;
37
 
38
/** Returns the current IMP for the given class and selector.
39
 *
40
 *  @param aClass The class to use.
41
 *  @param selector The selector to find the implementation of.
42
 *  @param isClassSelector A BOOL specifying whether the selector is a class or instance selector.
43
 *  @return The implementation of the selector in the runtime.
44
 */
45
+ (nullable IMP)currentImplementationForClass:(Class)aClass
46
                                     selector:(SEL)selector
47
                              isClassSelector:(BOOL)isClassSelector;
48
 
49
/** Checks the runtime to see if a selector exists on a class. If a property is declared as
50
 *  @dynamic, we have a reverse swizzling situation, where the implementation of a method exists
51
 *  only in concrete subclasses, and NOT in the superclass. We can detect that situation using
52
 *  this helper method. Similarly, we can detect situations where a class doesn't implement a
53
 *  protocol method.
54
 *
55
 *  @param selector The selector to check for.
56
 *  @param aClass The class to check.
57
 *  @param isClassSelector A BOOL specifying whether the selector is a class or instance selector.
58
 *  @return YES if the method was found in this selector/class combination, NO otherwise.
59
 */
60
+ (BOOL)selector:(SEL)selector existsInClass:(Class)aClass isClassSelector:(BOOL)isClassSelector;
61
 
62
/** Returns a list of all Objective-C (and not primitive) ivars contained by the given object.
63
 *
64
 *  @param object The object whose ivars will be iterated.
65
 *  @return The list of ivar objects.
66
 */
67
+ (NSArray<id> *)ivarObjectsForObject:(id)object;
68
 
69
@end
70
 
71
NS_ASSUME_NONNULL_END