├── BKRecursiveDescription ├── NSArray+BKRecursiveDescription.h ├── NSSet+BKRecursiveDescription.h ├── NSDictionary+BKRecursiveDescription.h ├── BKRecursiveDescription.h ├── BKDescribable.h ├── NSSet+BKRecursiveDescription.m ├── NSDictionary+BKRecursiveDescription.m ├── NSArray+BKRecursiveDescription.m ├── NSObject+BKRecursiveDescription.m └── NSObject+BKRecursiveDescription.h ├── BKRecursiveDescription.podspec ├── LICENSE ├── BKRecursiveDescription.xcodeproj ├── xcshareddata │ └── xcschemes │ │ └── BKRecursiveDescription.xcscheme └── project.pbxproj ├── .gitignore └── README.md /BKRecursiveDescription/NSArray+BKRecursiveDescription.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-present 650 Industries. All rights reserved. 2 | 3 | @import Foundation; 4 | 5 | @interface NSArray (BKRecursiveDescription) 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /BKRecursiveDescription/NSSet+BKRecursiveDescription.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-present 650 Industries. All rights reserved. 2 | 3 | @import Foundation; 4 | 5 | @interface NSSet (BKRecursiveDescription) 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /BKRecursiveDescription/NSDictionary+BKRecursiveDescription.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-present 650 Industries. All rights reserved. 2 | 3 | @import Foundation; 4 | 5 | @interface NSDictionary (BKRecursiveDescription) 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /BKRecursiveDescription/BKRecursiveDescription.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-present 650 Industries. All rights reserved. 2 | 3 | #import 4 | #import 5 | -------------------------------------------------------------------------------- /BKRecursiveDescription/BKDescribable.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-present 650 Industries. All rights reserved. 2 | 3 | @import Foundation; 4 | 5 | @protocol BKDescribable 6 | 7 | @optional 8 | - (void)bk_addRecursiveDescriptionToString:(NSMutableString *)string level:(NSUInteger)level; 9 | 10 | @end 11 | 12 | @interface NSObject () 13 | @end 14 | -------------------------------------------------------------------------------- /BKRecursiveDescription/NSSet+BKRecursiveDescription.m: -------------------------------------------------------------------------------- 1 | // Copyright 2014-present 650 Industries. All rights reserved. 2 | 3 | #import "NSSet+BKRecursiveDescription.h" 4 | 5 | #import "BKDescribable.h" 6 | #import "NSObject+BKRecursiveDescription.h" 7 | 8 | @implementation NSSet (BKRecursiveDescription) 9 | 10 | - (void)bk_addRecursiveDescriptionToString:(NSMutableString *)string level:(NSUInteger)level 11 | { 12 | DESCRIBE_SELF(string, self); 13 | 14 | for (NSObject *object in self) { 15 | DESCRIBE_OBJECT(string, level, @"[*]", object); 16 | } 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /BKRecursiveDescription/NSDictionary+BKRecursiveDescription.m: -------------------------------------------------------------------------------- 1 | // Copyright 2014-present 650 Industries. All rights reserved. 2 | 3 | #import "NSDictionary+BKRecursiveDescription.h" 4 | 5 | #import "BKDescribable.h" 6 | #import "NSObject+BKRecursiveDescription.h" 7 | 8 | @implementation NSDictionary (BKRecursiveDescription) 9 | 10 | - (void)bk_addRecursiveDescriptionToString:(NSMutableString *)string level:(NSUInteger)level 11 | { 12 | DESCRIBE_SELF(string, self); 13 | 14 | for (NSObject *key in self) { 15 | NSString *name = [NSString stringWithFormat:@"[%@]", [key description]]; 16 | DESCRIBE_OBJECT(string, level, name, self[key]); 17 | } 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /BKRecursiveDescription/NSArray+BKRecursiveDescription.m: -------------------------------------------------------------------------------- 1 | // Copyright 2014-present 650 Industries. All rights reserved. 2 | 3 | #import "NSArray+BKRecursiveDescription.h" 4 | 5 | #import "BKDescribable.h" 6 | #import "NSObject+BKRecursiveDescription.h" 7 | 8 | @implementation NSArray (BKRecursiveDescription) 9 | 10 | - (void)bk_addRecursiveDescriptionToString:(NSMutableString *)string level:(NSUInteger)level 11 | { 12 | DESCRIBE_SELF(string, self); 13 | 14 | unsigned int index = 0; 15 | for (NSObject *object in self) { 16 | NSString *name = [NSString stringWithFormat:@"[%u]", index]; 17 | DESCRIBE_OBJECT(string, level, name, object); 18 | index++; 19 | } 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /BKRecursiveDescription.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "BKRecursiveDescription" 3 | s.version = "0.0.1" 4 | s.summary = "A very simple interface to enable detailed, recursive descriptions of objects and their properties with a minimum amount of work." 5 | s.homepage = "https://github.com/Basket/BKRecursiveDescription" 6 | s.license = 'MIT' 7 | s.author = { "Andrew Toulouse" => "andrew@atoulou.se" } 8 | s.source = { :git => "https://github.com/Basket/BKRecursiveDescription.git", :tag => s.version.to_s } 9 | 10 | s.platform = :ios, '7.0' 11 | s.requires_arc = true 12 | 13 | s.source_files = 'BKRecursiveDescription/*.{h,m}' 14 | s.public_header_files = 'BKRecursiveDescription/BKRecursiveDescription.h', 15 | 'BKRecursiveDescription/BKDescribable.h', 16 | 'BKRecursiveDescription/NSObject+BKRecursiveDescription.h' 17 | s.frameworks = 'Foundation' 18 | s.xcconfig = { 19 | 'GCC_C_LANGUAGE_STANDARD' => 'gnu11' 20 | } 21 | 22 | end 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 650 Industries, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /BKRecursiveDescription/NSObject+BKRecursiveDescription.m: -------------------------------------------------------------------------------- 1 | // Copyright 2014-present 650 Industries. All rights reserved. 2 | 3 | #import "NSObject+BKRecursiveDescription.h" 4 | 5 | #import "BKDescribable.h" 6 | 7 | static const NSUInteger indentWidth = 2; 8 | 9 | @implementation NSObject (BKRecursiveDescription) 10 | 11 | - (NSString *)bk_recursiveDescription 12 | { 13 | return [self bk_describeLevel:0]; 14 | } 15 | 16 | - (NSString *)bk_describeLevel:(NSUInteger)level withKey:(NSString *)key 17 | { 18 | NSString *tab = 19 | [[@"" stringByPaddingToLength:indentWidth - 1 withString:@" " startingAtIndex:0] stringByAppendingString:@"|"]; 20 | NSString *indent = [@"" stringByPaddingToLength:indentWidth * level withString:tab startingAtIndex:0]; 21 | 22 | NSMutableString *string = [[NSMutableString alloc] initWithString:indent]; 23 | if (key) { 24 | // Currently, showing collection count only supports collections that implement fast enumeration, and assumes that 25 | // -count is sane and returns NSUInteger. 26 | if ([self conformsToProtocol:@protocol(NSFastEnumeration)]) { 27 | [string appendFormat:@"%@{count=%lu} = ", key, (unsigned long)[(id)self count]]; 28 | } else { 29 | [string appendFormat:@"%@ = ", key]; 30 | } 31 | } 32 | 33 | if ([self respondsToSelector:@selector(bk_addRecursiveDescriptionToString:level:)]) { 34 | [self bk_addRecursiveDescriptionToString:string level:level]; 35 | } else { 36 | [string appendString:[self description]]; 37 | } 38 | 39 | [string appendString:@"\n"]; 40 | return [string copy]; 41 | } 42 | 43 | - (NSString *)bk_describeLevel:(NSUInteger)level 44 | { 45 | return [self bk_describeLevel:level withKey:nil]; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /BKRecursiveDescription.xcodeproj/xcshareddata/xcschemes/BKRecursiveDescription.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 60 | 61 | 67 | 68 | 69 | 70 | 72 | 73 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ######################### 2 | # .gitignore file for Xcode4 / OS X Source projects 3 | # 4 | # Version 2.0 5 | # For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects 6 | # 7 | # 2013 updates: 8 | # - fixed the broken "save personal Schemes" 9 | # 10 | # NB: if you are storing "built" products, this WILL NOT WORK, 11 | # and you should use a different .gitignore (or none at all) 12 | # This file is for SOURCE projects, where there are many extra 13 | # files that we want to exclude 14 | # 15 | ######################### 16 | 17 | ##### 18 | # OS X temporary files that should never be committed 19 | 20 | .DS_Store 21 | *.swp 22 | *.lock 23 | profile 24 | 25 | 26 | #### 27 | # Xcode temporary files that should never be committed 28 | # 29 | # NB: NIB/XIB files still exist even on Storyboard projects, so we want this... 30 | 31 | *~.nib 32 | 33 | 34 | #### 35 | # Xcode build files - 36 | # 37 | # NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData" 38 | 39 | DerivedData/ 40 | 41 | # NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build" 42 | 43 | build/ 44 | 45 | 46 | ##### 47 | # Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups) 48 | # 49 | # This is complicated: 50 | # 51 | # SOMETIMES you need to put this file in version control. 52 | # Apple designed it poorly - if you use "custom executables", they are 53 | # saved in this file. 54 | # 99% of projects do NOT use those, so they do NOT want to version control this file. 55 | # ..but if you're in the 1%, comment out the line "*.pbxuser" 56 | 57 | *.pbxuser 58 | *.mode1v3 59 | *.mode2v3 60 | *.perspectivev3 61 | # NB: also, whitelist the default ones, some projects need to use these 62 | !default.pbxuser 63 | !default.mode1v3 64 | !default.mode2v3 65 | !default.perspectivev3 66 | 67 | 68 | #### 69 | # Xcode 4 - semi-personal settings 70 | # 71 | # 72 | # OPTION 1: --------------------------------- 73 | # throw away ALL personal settings (including custom schemes! 74 | # - unless they are "shared") 75 | # 76 | # NB: this is exclusive with OPTION 2 below 77 | xcuserdata 78 | 79 | # OPTION 2: --------------------------------- 80 | # get rid of ALL personal settings, but KEEP SOME OF THEM 81 | # - NB: you must manually uncomment the bits you want to keep 82 | # 83 | # NB: this is exclusive with OPTION 1 above 84 | # 85 | #xcuserdata/**/* 86 | 87 | # (requires option 2 above): Personal Schemes 88 | # 89 | #!xcuserdata/**/xcschemes/* 90 | 91 | #### 92 | # XCode 4 workspaces - more detailed 93 | # 94 | # Workspaces are important! They are a core feature of Xcode - don't exclude them :) 95 | # 96 | # Workspace layout is quite spammy. For reference: 97 | # 98 | # /(root)/ 99 | # /(project-name).xcodeproj/ 100 | # project.pbxproj 101 | # /project.xcworkspace/ 102 | # contents.xcworkspacedata 103 | # /xcuserdata/ 104 | # /(your name)/xcuserdatad/ 105 | # UserInterfaceState.xcuserstate 106 | # /xcsshareddata/ 107 | # /xcschemes/ 108 | # (shared scheme name).xcscheme 109 | # /xcuserdata/ 110 | # /(your name)/xcuserdatad/ 111 | # (private scheme).xcscheme 112 | # xcschememanagement.plist 113 | # 114 | # 115 | 116 | #### 117 | # Xcode 4 - Deprecated classes 118 | # 119 | # Allegedly, if you manually "deprecate" your classes, they get moved here. 120 | # 121 | # We're using source-control, so this is a "feature" that we do not want! 122 | 123 | *.moved-aside 124 | 125 | 126 | #### 127 | # UNKNOWN: recommended by others, but I can't discover what these files are 128 | # 129 | # ...none. Everything is now explained. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BKRecursiveDescription 2 | 3 | ## Installation 4 | 5 | 1. Add BKRecursiveDescription to your Podfile. 6 | 2. In your terminal, run `pod install`. 7 | 8 | ## Usage 9 | 10 | 11 | 1. Add `#import ` to your source file (or to your prefix header, if you want to access it anywhere in your project). 12 | 2. Implement the method `- (void)bk_addRecursiveDescriptionToString:(NSMutableString *)string level:(NSUInteger)level` on your class. 13 | 3. Call `[yourObject bk_recursiveDescription]` on your object to get an `NSString` containing the recursive description of your object. 14 | 15 | ```objc 16 | // Implemented in a class named "BKSomeClass" (adapted from the example project) 17 | - (void)bk_addRecursiveDescriptionToString:(NSMutableString *)string level:(NSUInteger)level 18 | { 19 | DESCRIBE_SELF(string, self); 20 | 21 | DESCRIBE_VARIABLE(string, level, _drawerPosition); // enum 22 | DESCRIBE_VARIABLE(string, level, _bounds); // CGRect 23 | DESCRIBE_VARIABLE(string, level, _drawerOffset); // CGFloat 24 | DESCRIBE_VARIABLE(string, level, _drawerInsets); // UIEdgeInsets 25 | DESCRIBE_VARIABLE(string, level, _acceptSpec); // NSObject with its own recursive description method 26 | } 27 | ``` 28 | 29 | Outputs: 30 | 31 | ``` 32 | 33 | |_drawerPosition = (unsigned int)1 34 | |_bounds = (CGRect){{0, 0}, {320, 568}} 35 | |_drawerOffset = (float)198.500000 36 | |_drawerInsets = (UIEdgeInsets){44, 0, 172.5, 0} 37 | |_acceptSpec = 38 | | |_bounds = (CGRect){{0, 0}, {40, 40}} 39 | | |_center = (CGPoint){280, 168.5} 40 | | |_alpha = (float)0.473901 41 | ``` 42 | 43 | ## FAQ 44 | 45 | **Q:** What's with that `string` and `level` stuff in the macros? 46 | **A:** It might not always be practical to recursively *implement* a recursive description method on a tree of objects, and some wiggle room is needed for those implementations. As such, the raw string that's being built is provided directly. This also allows for custom strings to be inserted, such as headers or separators, when organizing the description of properties. 47 | 48 | The level allows collections to indent their contents appropriately - or, again, for custom implementations to tweak the description levels as needed for complex descriptions if needed. **Most developers need not worry about this, and can simply pass the parameters in unchanged.** 49 | 50 | **Q:** C11 generics? 51 | **A:** Yep. They're disabled if you don't support them, though, via `#if __has_feature(c_generic_selections)`. You can still access the underlying C functions that the generic macro resolves to, i.e. `_RD_DESCRIBE_CGRECT`, if you prefer. Those methods' declarations specify that they should always be inlined. 52 | 53 | Incidentally, the C functions are necessary because C11 generics only seem to select __expressions__, not __statements__. 54 | 55 | **Q:** Why the `do {} while(0)` wrapping? Does that even do anything? 56 | **A:** Yep - it's par for the course for C preprocessor programming. It groups a series of statements into one, so that the curly braces don't disrupt, for example, braceless if statements when the macros are expanded. 57 | 58 | ## Documentation 59 | 60 | ### The magic 61 | 62 | * `DESCRIBE_VARIABLE(string, level, variable)` 63 | * Stringifies and uses the expression `variable` as the name in the description, then resolves the macro to `DESCRIBE_VALUE`. 64 | * `DESCRIBE_VALUE(string, level, name, value)` 65 | * Appends a variable to `string`, formatted according to parameter type, using C11 generic expressions. Supports `float`,`double`, `short`, `unsigned short`, `int`, `unsigned int`, `long`, `unsigned long`, `long long`, `unsigned long long`, `BOOL`, `CGPoint`, `CGRect`, `UIEdgeInsets`, and `NSObject` (+ subclasses). 66 | 67 | ### The usual 68 | 69 | * `DESCRIBE_SELF(string, object)` 70 | * Appends the class name of `object` followed by its pointer value to `string`. By convention, always the first statement in the recursive description implementation. 71 | * `DESCRIBE_OBJECT(string, level, name, object)` 72 | * Appends the description for `object` with the given `name` to `string`. If `object` supports recursive description, its recursive description will be used. `object` may be nil. 73 | * `DESCRIBE_VALUE_WITH_FORMAT(string, level, name, format, value)` 74 | * Appends a description with an explicit format string to `string`. -------------------------------------------------------------------------------- /BKRecursiveDescription/NSObject+BKRecursiveDescription.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-present 650 Industries. All rights reserved. 2 | 3 | @import Foundation; 4 | @import UIKit.UIGeometry; 5 | 6 | @interface NSObject (BKRecursiveDescription) 7 | 8 | - (NSString *)bk_recursiveDescription; 9 | - (NSString *)bk_describeLevel:(NSUInteger)level; 10 | - (NSString *)bk_describeLevel:(NSUInteger)level withKey:(NSString *)key; 11 | 12 | @end 13 | 14 | #define DESCRIBE_SELF(string, object) [string appendFormat:@"<%@: %p>\n", NSStringFromClass([object class]), object] 15 | 16 | #define DESCRIBE_OBJECT(string, level, name, object) \ 17 | do { \ 18 | if (object) { \ 19 | [string appendString:[object bk_describeLevel:level + 1 withKey:name]]; \ 20 | } else { \ 21 | [string appendString:[@"(nil)" bk_describeLevel:level + 1 withKey:name]]; \ 22 | } \ 23 | } while(0) 24 | 25 | #define DESCRIBE_VALUE_WITH_FORMAT(string, level, name, format, value) \ 26 | do { \ 27 | [string appendString:[[NSString stringWithFormat:format, value] bk_describeLevel:level + 1 withKey:name]]; \ 28 | } while(0) 29 | 30 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_FLOAT(NSMutableString *string, NSUInteger level, NSString *name, float value) { 31 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(float)%f", value); 32 | } 33 | 34 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_DOUBLE(NSMutableString *string, NSUInteger level, NSString *name, double value) { 35 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(double)%f", value); 36 | } 37 | 38 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_SHORT(NSMutableString *string, NSUInteger level, NSString *name, short value) { 39 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(short)%d", value); 40 | } 41 | 42 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_UNSIGNED_SHORT(NSMutableString *string, NSUInteger level, NSString *name, unsigned short value) { 43 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(unsigned short)%u", value); 44 | } 45 | 46 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_INT(NSMutableString *string, NSUInteger level, NSString *name, int value) { 47 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(int)%d", value); 48 | } 49 | 50 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_UNSIGNED_INT(NSMutableString *string, NSUInteger level, NSString *name, unsigned int value) { 51 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(unsigned int)%u", value); 52 | } 53 | 54 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_LONG(NSMutableString *string, NSUInteger level, NSString *name, long value) { 55 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(long)%ld", value); 56 | } 57 | 58 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_UNSIGNED_LONG(NSMutableString *string, NSUInteger level, NSString *name, unsigned long value) { 59 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(unsigned long)%lu", value); 60 | } 61 | 62 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_LONG_LONG(NSMutableString *string, NSUInteger level, NSString *name, long long value) { 63 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(long long)%lld", value); 64 | } 65 | 66 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_UNSIGNED_LONG_LONG(NSMutableString *string, NSUInteger level, NSString *name, unsigned long long value) { 67 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(unsigned long long)%llu", value); 68 | } 69 | 70 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_BOOL(NSMutableString *string, NSUInteger level, NSString *name, BOOL value) { 71 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(BOOL)%@", value ? @"YES" : @"NO"); 72 | } 73 | 74 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_CGPOINT(NSMutableString *string, NSUInteger level, NSString *name, CGPoint value) { 75 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(CGPoint)%@", NSStringFromCGPoint(value)); 76 | } 77 | 78 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_CGRECT(NSMutableString *string, NSUInteger level, NSString *name, CGRect value) { 79 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(CGRect)%@", NSStringFromCGRect(value)); 80 | } 81 | 82 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_UIEDGEINSETS(NSMutableString *string, NSUInteger level, NSString *name, UIEdgeInsets value) { 83 | DESCRIBE_VALUE_WITH_FORMAT(string, level, name, @"(UIEdgeInsets)%@", NSStringFromUIEdgeInsets(value)); 84 | } 85 | 86 | __attribute__((__always_inline__)) static inline void _RD_DESCRIBE_PROBABLY_OBJECT(NSMutableString *string, NSUInteger level, NSString *name, id value) { 87 | DESCRIBE_OBJECT(string, level, name, value); 88 | } 89 | 90 | 91 | #if __has_feature(c_generic_selections) 92 | #define DESCRIBE_VALUE(string, level, name, value) _Generic((value), \ 93 | float: _RD_DESCRIBE_FLOAT, \ 94 | double: _RD_DESCRIBE_DOUBLE, \ 95 | short: _RD_DESCRIBE_SHORT, \ 96 | unsigned short: _RD_DESCRIBE_UNSIGNED_SHORT, \ 97 | int: _RD_DESCRIBE_INT, \ 98 | unsigned int: _RD_DESCRIBE_UNSIGNED_INT, \ 99 | long: _RD_DESCRIBE_LONG, \ 100 | unsigned long: _RD_DESCRIBE_UNSIGNED_LONG, \ 101 | long long: _RD_DESCRIBE_LONG_LONG, \ 102 | unsigned long long: _RD_DESCRIBE_UNSIGNED_LONG_LONG, \ 103 | BOOL: _RD_DESCRIBE_BOOL, \ 104 | CGPoint: _RD_DESCRIBE_CGPOINT, \ 105 | CGRect: _RD_DESCRIBE_CGRECT, \ 106 | UIEdgeInsets: _RD_DESCRIBE_UIEDGEINSETS, \ 107 | default: _RD_DESCRIBE_PROBABLY_OBJECT \ 108 | )(string, level, name, value) 109 | 110 | #define DESCRIBE_VARIABLE(string, level, variable) DESCRIBE_VALUE(string, level, @#variable, variable) 111 | #endif 112 | -------------------------------------------------------------------------------- /BKRecursiveDescription.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6B581AB6198701F1005C3F79 /* BKRecursiveDescription.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6B581AB5198701F1005C3F79 /* BKRecursiveDescription.h */; }; 11 | 6B581AD519870213005C3F79 /* NSArray+BKRecursiveDescription.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B581AD119870213005C3F79 /* NSArray+BKRecursiveDescription.m */; }; 12 | 6B581AD619870213005C3F79 /* NSDictionary+BKRecursiveDescription.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B581AD219870213005C3F79 /* NSDictionary+BKRecursiveDescription.m */; }; 13 | 6B581AD719870213005C3F79 /* NSObject+BKRecursiveDescription.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B581AD319870213005C3F79 /* NSObject+BKRecursiveDescription.m */; }; 14 | 6B581AD819870213005C3F79 /* NSSet+BKRecursiveDescription.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B581AD419870213005C3F79 /* NSSet+BKRecursiveDescription.m */; }; 15 | 6B581AD91987021F005C3F79 /* NSObject+BKRecursiveDescription.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6B581ACD19870213005C3F79 /* NSObject+BKRecursiveDescription.h */; }; 16 | 6B581ADA1987021F005C3F79 /* BKDescribable.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6B581AD019870213005C3F79 /* BKDescribable.h */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXCopyFilesBuildPhase section */ 20 | 6B581AB0198701F1005C3F79 /* CopyFiles */ = { 21 | isa = PBXCopyFilesBuildPhase; 22 | buildActionMask = 2147483647; 23 | dstPath = "include/$(PRODUCT_NAME)"; 24 | dstSubfolderSpec = 16; 25 | files = ( 26 | 6B581ADA1987021F005C3F79 /* BKDescribable.h in CopyFiles */, 27 | 6B581AB6198701F1005C3F79 /* BKRecursiveDescription.h in CopyFiles */, 28 | 6B581AD91987021F005C3F79 /* NSObject+BKRecursiveDescription.h in CopyFiles */, 29 | ); 30 | runOnlyForDeploymentPostprocessing = 0; 31 | }; 32 | /* End PBXCopyFilesBuildPhase section */ 33 | 34 | /* Begin PBXFileReference section */ 35 | 6B581AB2198701F1005C3F79 /* libBKRecursiveDescription.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBKRecursiveDescription.a; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | 6B581AB5198701F1005C3F79 /* BKRecursiveDescription.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BKRecursiveDescription.h; sourceTree = ""; }; 37 | 6B581ACC19870213005C3F79 /* NSSet+BKRecursiveDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSSet+BKRecursiveDescription.h"; sourceTree = ""; }; 38 | 6B581ACD19870213005C3F79 /* NSObject+BKRecursiveDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BKRecursiveDescription.h"; sourceTree = ""; }; 39 | 6B581ACE19870213005C3F79 /* NSDictionary+BKRecursiveDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+BKRecursiveDescription.h"; sourceTree = ""; }; 40 | 6B581ACF19870213005C3F79 /* NSArray+BKRecursiveDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+BKRecursiveDescription.h"; sourceTree = ""; }; 41 | 6B581AD019870213005C3F79 /* BKDescribable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BKDescribable.h; sourceTree = ""; }; 42 | 6B581AD119870213005C3F79 /* NSArray+BKRecursiveDescription.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+BKRecursiveDescription.m"; sourceTree = ""; }; 43 | 6B581AD219870213005C3F79 /* NSDictionary+BKRecursiveDescription.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+BKRecursiveDescription.m"; sourceTree = ""; }; 44 | 6B581AD319870213005C3F79 /* NSObject+BKRecursiveDescription.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BKRecursiveDescription.m"; sourceTree = ""; }; 45 | 6B581AD419870213005C3F79 /* NSSet+BKRecursiveDescription.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSSet+BKRecursiveDescription.m"; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | 6B581AAF198701F1005C3F79 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXFrameworksBuildPhase section */ 57 | 58 | /* Begin PBXGroup section */ 59 | 6B581AA9198701F1005C3F79 = { 60 | isa = PBXGroup; 61 | children = ( 62 | 6B581AB4198701F1005C3F79 /* BKRecursiveDescription */, 63 | 6B581AB3198701F1005C3F79 /* Products */, 64 | ); 65 | sourceTree = ""; 66 | }; 67 | 6B581AB3198701F1005C3F79 /* Products */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | 6B581AB2198701F1005C3F79 /* libBKRecursiveDescription.a */, 71 | ); 72 | name = Products; 73 | sourceTree = ""; 74 | }; 75 | 6B581AB4198701F1005C3F79 /* BKRecursiveDescription */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 6B581AD019870213005C3F79 /* BKDescribable.h */, 79 | 6B581AB5198701F1005C3F79 /* BKRecursiveDescription.h */, 80 | 6B581ACF19870213005C3F79 /* NSArray+BKRecursiveDescription.h */, 81 | 6B581AD119870213005C3F79 /* NSArray+BKRecursiveDescription.m */, 82 | 6B581ACE19870213005C3F79 /* NSDictionary+BKRecursiveDescription.h */, 83 | 6B581AD219870213005C3F79 /* NSDictionary+BKRecursiveDescription.m */, 84 | 6B581ACD19870213005C3F79 /* NSObject+BKRecursiveDescription.h */, 85 | 6B581AD319870213005C3F79 /* NSObject+BKRecursiveDescription.m */, 86 | 6B581ACC19870213005C3F79 /* NSSet+BKRecursiveDescription.h */, 87 | 6B581AD419870213005C3F79 /* NSSet+BKRecursiveDescription.m */, 88 | ); 89 | path = BKRecursiveDescription; 90 | sourceTree = ""; 91 | }; 92 | /* End PBXGroup section */ 93 | 94 | /* Begin PBXNativeTarget section */ 95 | 6B581AB1198701F1005C3F79 /* BKRecursiveDescription */ = { 96 | isa = PBXNativeTarget; 97 | buildConfigurationList = 6B581AC6198701F1005C3F79 /* Build configuration list for PBXNativeTarget "BKRecursiveDescription" */; 98 | buildPhases = ( 99 | 6B581AAE198701F1005C3F79 /* Sources */, 100 | 6B581AAF198701F1005C3F79 /* Frameworks */, 101 | 6B581AB0198701F1005C3F79 /* CopyFiles */, 102 | ); 103 | buildRules = ( 104 | ); 105 | dependencies = ( 106 | ); 107 | name = BKRecursiveDescription; 108 | productName = BKRecursiveDescription; 109 | productReference = 6B581AB2198701F1005C3F79 /* libBKRecursiveDescription.a */; 110 | productType = "com.apple.product-type.library.static"; 111 | }; 112 | /* End PBXNativeTarget section */ 113 | 114 | /* Begin PBXProject section */ 115 | 6B581AAA198701F1005C3F79 /* Project object */ = { 116 | isa = PBXProject; 117 | attributes = { 118 | LastUpgradeCheck = 0600; 119 | ORGANIZATIONNAME = "650 Industries, Inc."; 120 | TargetAttributes = { 121 | 6B581AB1198701F1005C3F79 = { 122 | CreatedOnToolsVersion = 6.0; 123 | }; 124 | }; 125 | }; 126 | buildConfigurationList = 6B581AAD198701F1005C3F79 /* Build configuration list for PBXProject "BKRecursiveDescription" */; 127 | compatibilityVersion = "Xcode 3.2"; 128 | developmentRegion = English; 129 | hasScannedForEncodings = 0; 130 | knownRegions = ( 131 | en, 132 | ); 133 | mainGroup = 6B581AA9198701F1005C3F79; 134 | productRefGroup = 6B581AB3198701F1005C3F79 /* Products */; 135 | projectDirPath = ""; 136 | projectRoot = ""; 137 | targets = ( 138 | 6B581AB1198701F1005C3F79 /* BKRecursiveDescription */, 139 | ); 140 | }; 141 | /* End PBXProject section */ 142 | 143 | /* Begin PBXSourcesBuildPhase section */ 144 | 6B581AAE198701F1005C3F79 /* Sources */ = { 145 | isa = PBXSourcesBuildPhase; 146 | buildActionMask = 2147483647; 147 | files = ( 148 | 6B581AD519870213005C3F79 /* NSArray+BKRecursiveDescription.m in Sources */, 149 | 6B581AD619870213005C3F79 /* NSDictionary+BKRecursiveDescription.m in Sources */, 150 | 6B581AD719870213005C3F79 /* NSObject+BKRecursiveDescription.m in Sources */, 151 | 6B581AD819870213005C3F79 /* NSSet+BKRecursiveDescription.m in Sources */, 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | /* End PBXSourcesBuildPhase section */ 156 | 157 | /* Begin XCBuildConfiguration section */ 158 | 6B581AC4198701F1005C3F79 /* Debug */ = { 159 | isa = XCBuildConfiguration; 160 | buildSettings = { 161 | ALWAYS_SEARCH_USER_PATHS = NO; 162 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 163 | CLANG_CXX_LIBRARY = "libc++"; 164 | CLANG_ENABLE_MODULES = YES; 165 | CLANG_ENABLE_OBJC_ARC = YES; 166 | CLANG_WARN_BOOL_CONVERSION = YES; 167 | CLANG_WARN_CONSTANT_CONVERSION = YES; 168 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 169 | CLANG_WARN_EMPTY_BODY = YES; 170 | CLANG_WARN_ENUM_CONVERSION = YES; 171 | CLANG_WARN_INT_CONVERSION = YES; 172 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 173 | CLANG_WARN_UNREACHABLE_CODE = YES; 174 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 175 | COPY_PHASE_STRIP = NO; 176 | ENABLE_STRICT_OBJC_MSGSEND = YES; 177 | GCC_C_LANGUAGE_STANDARD = gnu99; 178 | GCC_DYNAMIC_NO_PIC = NO; 179 | GCC_OPTIMIZATION_LEVEL = 0; 180 | GCC_PREPROCESSOR_DEFINITIONS = ( 181 | "DEBUG=1", 182 | "$(inherited)", 183 | ); 184 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 185 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 186 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 187 | GCC_WARN_UNDECLARED_SELECTOR = YES; 188 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 189 | GCC_WARN_UNUSED_FUNCTION = YES; 190 | GCC_WARN_UNUSED_VARIABLE = YES; 191 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 192 | MTL_ENABLE_DEBUG_INFO = YES; 193 | ONLY_ACTIVE_ARCH = YES; 194 | SDKROOT = iphoneos; 195 | }; 196 | name = Debug; 197 | }; 198 | 6B581AC5198701F1005C3F79 /* Release */ = { 199 | isa = XCBuildConfiguration; 200 | buildSettings = { 201 | ALWAYS_SEARCH_USER_PATHS = NO; 202 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 203 | CLANG_CXX_LIBRARY = "libc++"; 204 | CLANG_ENABLE_MODULES = YES; 205 | CLANG_ENABLE_OBJC_ARC = YES; 206 | CLANG_WARN_BOOL_CONVERSION = YES; 207 | CLANG_WARN_CONSTANT_CONVERSION = YES; 208 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 209 | CLANG_WARN_EMPTY_BODY = YES; 210 | CLANG_WARN_ENUM_CONVERSION = YES; 211 | CLANG_WARN_INT_CONVERSION = YES; 212 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 213 | CLANG_WARN_UNREACHABLE_CODE = YES; 214 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 215 | COPY_PHASE_STRIP = YES; 216 | ENABLE_NS_ASSERTIONS = NO; 217 | ENABLE_STRICT_OBJC_MSGSEND = YES; 218 | GCC_C_LANGUAGE_STANDARD = gnu99; 219 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 220 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 221 | GCC_WARN_UNDECLARED_SELECTOR = YES; 222 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 223 | GCC_WARN_UNUSED_FUNCTION = YES; 224 | GCC_WARN_UNUSED_VARIABLE = YES; 225 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 226 | MTL_ENABLE_DEBUG_INFO = NO; 227 | SDKROOT = iphoneos; 228 | VALIDATE_PRODUCT = YES; 229 | }; 230 | name = Release; 231 | }; 232 | 6B581AC7198701F1005C3F79 /* Debug */ = { 233 | isa = XCBuildConfiguration; 234 | buildSettings = { 235 | OTHER_LDFLAGS = "-ObjC"; 236 | PRODUCT_NAME = "$(TARGET_NAME)"; 237 | SKIP_INSTALL = YES; 238 | }; 239 | name = Debug; 240 | }; 241 | 6B581AC8198701F1005C3F79 /* Release */ = { 242 | isa = XCBuildConfiguration; 243 | buildSettings = { 244 | OTHER_LDFLAGS = "-ObjC"; 245 | PRODUCT_NAME = "$(TARGET_NAME)"; 246 | SKIP_INSTALL = YES; 247 | }; 248 | name = Release; 249 | }; 250 | /* End XCBuildConfiguration section */ 251 | 252 | /* Begin XCConfigurationList section */ 253 | 6B581AAD198701F1005C3F79 /* Build configuration list for PBXProject "BKRecursiveDescription" */ = { 254 | isa = XCConfigurationList; 255 | buildConfigurations = ( 256 | 6B581AC4198701F1005C3F79 /* Debug */, 257 | 6B581AC5198701F1005C3F79 /* Release */, 258 | ); 259 | defaultConfigurationIsVisible = 0; 260 | defaultConfigurationName = Release; 261 | }; 262 | 6B581AC6198701F1005C3F79 /* Build configuration list for PBXNativeTarget "BKRecursiveDescription" */ = { 263 | isa = XCConfigurationList; 264 | buildConfigurations = ( 265 | 6B581AC7198701F1005C3F79 /* Debug */, 266 | 6B581AC8198701F1005C3F79 /* Release */, 267 | ); 268 | defaultConfigurationIsVisible = 0; 269 | defaultConfigurationName = Release; 270 | }; 271 | /* End XCConfigurationList section */ 272 | }; 273 | rootObject = 6B581AAA198701F1005C3F79 /* Project object */; 274 | } 275 | --------------------------------------------------------------------------------