-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNSObject+Explain.h
More file actions
76 lines (67 loc) · 3.69 KB
/
NSObject+Explain.h
File metadata and controls
76 lines (67 loc) · 3.69 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright 2012 Florian Agsteiner
*/
#import <Foundation/NSObject.h>
@class NSArray;
/**
* Used by NSFetchRequest+Explain for pretty printing
*/
@interface NSObject (Explain)
/**
* Return a short object description (without newlines)
*
* @return The description
*/
- (NSString*) explainDescription;
/**
* Creates a tree description by asking for a description of each node and a list of children.
*
* The children can be a list of objects, an object or nil, the algorithm will do a depth first description.
* Set the children to nil to terminate a subtree, it is also the default value.
*
* @param root The root object to start the recursion with (e.g. a UIWindow)
* @param @recursiveBlock A block that returns a description for the given node and a list of childen (e.g. the subviews)
* @return The description
*/
+ (NSString*)recursiveTreeDescriptionWithRoot:(id)root recursiveBlockReturningChildren:(NSString* (^)(id node, NSArray** children)) recursiveBlock;
/**
* Creates a tree description by asking for a description of each node and a list of children.
*
* It uses selectors to be able to use this method in the debugger.
* A few examples you can try:
*
* 1) Create a recursive view description
* po [NSObject recursiveTreeDescriptionWithRoot:(id)[UIWindow keyWindow] descriptionSelector:@selector(description) recursiveChildrenSelector:@selector(subviews)]
*
* 2) Create a recursive view description and show the controllers when possible (uses private api but who cares in the dubugger ;-))
* po [NSObject recursiveTreeDescriptionWithRoot:(id)[UIWindow keyWindow] descriptionSelector:@selector(_viewDelegate) recursiveChildrenSelector:@selector(subviews)]
*
* 3) Create a description of the responder chain of a given pointer
* po [NSObject recursiveTreeDescriptionWithRoot:(id)0xdeadbeef descriptionSelector:@selector(description) recursiveChildrenSelector:@selector(nextResponder)]
*
* @param root The root object to start the recursion with (e.g. a UIWindow)
* @param descriptionSelector The selector to return the string (e.g. @selector(description))
* @param recursiveChildrenSelector The selector to return the children, a list, single object, or nil (e.g. @selector(description))
*/
+ (NSString*)recursiveTreeDescriptionWithRoot:(id)root descriptionSelector:(SEL)descriptionSelector recursiveChildrenSelector:(SEL)recursiveChildrenSelector;
/**
* Creates a tree description by asking for a description of each node and a list of children, it will start with the current object.
*
* The children can be a list of objects, an object or nil, the algorithm will do a depth first description.
* Set the children to nil to terminate a subtree, it is also the default value.
*
* @param @recursiveBlock A block that returns a description for the given node and a list of childen (e.g. the subviews)
* @return The description
*/
- (NSString*)recursiveTreeDescriptionWithRecursiveBlockReturningChildren:(NSString* (^)(id node, NSArray** children)) recursiveBlock;
/**
* Creates a tree description by asking for a description of each node and a list of children, it will start with the current object.
*
* It uses selectors to be able to use this method in the debugger.
* @see recursiveTreeDescriptionWithRoot:descriptionSelector:recursiveChildrenSelector:
*
* @param descriptionSelector The selector to return the string (e.g. @selector(description))
* @param recursiveChildrenSelector The selector to return the children, a list, single object, or nil (e.g. @selector(description))
*/
- (NSString*)recursiveTreeDescriptionWithDescriptionSelector:(SEL)descriptionSelector recursiveChildrenSelector:(SEL)recursiveChildrenSelector;
@end