├── .DS_Store ├── .gitignore ├── LcPrint ├── LcPrint+LLDB.h ├── LcPrint+LLDB.m ├── LcPrint.h ├── LcPrintInner.h ├── LcPrintInner.m ├── LcPrintMacro.h ├── LcPrintObj.h ├── LcPrintObj.m ├── LcPrintUtility.h ├── LcPrintUtility.m ├── LcPrintVar.h ├── LcPrintVar.m ├── LcPrintViews.h ├── LcPrintViews.m ├── LcStringFromStruct.h └── LcStringFromStruct.m ├── PrintValueSample ├── PrintValueSample.xcodeproj │ └── project.pbxproj └── PrintValueSample │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── Model.h │ ├── Model.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lianchengjiang/PrintValue/59a5a2a4084354d34d69dcd3feaad9aa682edc74/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | PrintValueSample 2 | project.xcworkspace 3 | xcuserdata 4 | -------------------------------------------------------------------------------- /LcPrint/LcPrint+LLDB.h: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrint+LLDB.h 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/7. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import "LcPrintMacro.h" 10 | 11 | #if _LC_VALID 12 | 13 | 14 | extern void o(id obj); //print object's value. you can use it in lldb: `p o()` 15 | extern void oo(id obj); //circle print super class's value. use it in lldb: `p oo()` 16 | extern void v(id view); //circle print view's subview. use it in lldb: `p v()` 17 | extern void i(id obj); //print object's inner. use it in lldb: `p i()` 18 | extern void ii(id obj); //circle print super class of object's inner. use it in lldb: `p ii()` 19 | 20 | #endif -------------------------------------------------------------------------------- /LcPrint/LcPrint+LLDB.m: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrint+LLDB.m 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/7. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "LcPrint+LLDB.h" 12 | #import "LcPrintObj.h" 13 | #import "LcPrintViews.h" 14 | #import "LcPrintMacro.h" 15 | #import "LcPrintInner.h" 16 | 17 | #if _LC_VALID 18 | 19 | void o(id obj) 20 | { 21 | printf("%s\n",[describeObj(obj, NO) UTF8String]); 22 | } 23 | 24 | void oo(id obj) 25 | { 26 | printf("%s\n",[describeObj(obj, YES) UTF8String]); 27 | } 28 | 29 | void v(id view) 30 | { 31 | if (![view isKindOfClass:[UIView class]]) { 32 | printf("this is not a view, please use 'p o(x)' instead\n"); 33 | } 34 | 35 | printf("%s\n",[describeViews(view) UTF8String]); 36 | } 37 | 38 | void i(id obj) 39 | { 40 | printf("%s\n",[describInner(obj, NO) UTF8String]); 41 | } 42 | 43 | void ii(id obj) 44 | { 45 | printf("%s\n",[describInner(obj, YES) UTF8String]); 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /LcPrint/LcPrint.h: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrint.h 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/5. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "LcPrintViews.h" 11 | #import "LcPrintObj.h" 12 | #import "LcPrintVar.h" 13 | #import "LcPrintMacro.h" 14 | 15 | 16 | 17 | #if _LC_VALID 18 | 19 | #define __FILE_PATH__ [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String] 20 | #define LcPrint(x) printf("%s, %s, Line:%d\n❤️%s = %s\n", __FILE_PATH__, __PRETTY_FUNCTION__, __LINE__, __STRING(x), [describeVar(@encode(typeof(x)),(x)) UTF8String]) 21 | 22 | #define LcPrintViews(x) printf("%s, %s, Line:%d\n❤️%s:\n%s\n", __FILE_PATH__, __PRETTY_FUNCTION__, __LINE__, __STRING(x), [describeViews(x) UTF8String]) 23 | 24 | 25 | #else 26 | 27 | 28 | #define LcPrint(x) 29 | #define LcPrintViews(x) 30 | 31 | #endif 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /LcPrint/LcPrintInner.h: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrintInner.h 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/8. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | extern NSString *describInner(id object, BOOL circlePrintSuper); 12 | -------------------------------------------------------------------------------- /LcPrint/LcPrintInner.m: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrintInner.m 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/8. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import "LcPrintInner.h" 10 | #import "LcPrintMacro.h" 11 | #import 12 | #import "LcPrintUtility.h" 13 | 14 | static inline NSString *__describeInner(id object, Class class, BOOL circle); 15 | 16 | NSString *describInner(id object, BOOL circlePrintSuper) 17 | { 18 | return __describeInner(object, object_getClass(object), circlePrintSuper); 19 | } 20 | 21 | static inline NSString *__describeVar(Class class) 22 | { 23 | NSMutableString *varString = [NSMutableString string]; 24 | [varString appendFormat:@"@Ivar{"]; 25 | NSArray *nameList = __lc_ivar_name_list(class); 26 | for (NSString *name in nameList) { 27 | [varString appendFormat:@"\n\t%@",name]; 28 | } 29 | [varString appendFormat:@"\n}"]; 30 | return varString; 31 | } 32 | 33 | static inline NSString *__describeProperty(Class class) 34 | { 35 | NSMutableString *propertyString = [NSMutableString string]; 36 | [propertyString appendFormat:@"@Property{"]; 37 | NSArray *nameList = __lc_property_name_list(class); 38 | for (NSString *name in nameList) { 39 | [propertyString appendFormat:@"\n\t%@",name]; 40 | } 41 | [propertyString appendFormat:@"\n}"]; 42 | return propertyString; 43 | } 44 | 45 | static inline NSString *__describeMethod(Class class) 46 | { 47 | NSMutableString *methodString = [NSMutableString string]; 48 | [methodString appendString:@"@Method{"]; 49 | 50 | //normal class 51 | NSArray *nameList = __lc_method_name_list(class); 52 | for (NSString *name in nameList) { 53 | [methodString appendFormat:@"\n\t-%@",name]; 54 | } 55 | 56 | //meta class 57 | const char *className = [NSStringFromClass(class) UTF8String]; 58 | NSArray *metaNameList = __lc_method_name_list(objc_getMetaClass(className)); 59 | for (NSString *name in metaNameList) { 60 | [methodString appendFormat:@"\n\t+%@",name]; 61 | } 62 | 63 | [methodString appendString:@"\n}"]; 64 | return methodString; 65 | } 66 | 67 | 68 | static inline NSString *__describeInner(id object, Class class, BOOL circle) 69 | { 70 | NSMutableString *describe = [NSMutableString string]; 71 | 72 | [describe appendFormat:@"(%@ *){",class]; 73 | //super class 74 | if (circle && ![NSObject isSubclassOfClass:class]) { 75 | NSString *superInner = __describeInner(object, class_getSuperclass(class), circle); 76 | [describe appendString:__lc_tap_string(__LcString(@"\n%@",superInner))]; 77 | } 78 | 79 | [describe appendString:__lc_tap_string(__LcString(@"\n%@",__describeVar(class)))]; 80 | [describe appendString:__lc_tap_string(__LcString(@"\n%@",__describeProperty(class)))]; 81 | [describe appendString:__lc_tap_string(__LcString(@"\n%@",__describeMethod(class)))]; 82 | [describe appendFormat:@"\n}(%@ *)",class]; 83 | return describe; 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /LcPrint/LcPrintMacro.h: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrintMacro.h 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/7. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | 10 | #define _LC_VALID_ONLY_DEBUG 1 11 | #define _LC_VALID (!_LC_VALID_ONLY_DEBUG||DEBUG) 12 | 13 | #define __LcString(fmt, ...) [NSString stringWithFormat:fmt, ##__VA_ARGS__] 14 | 15 | -------------------------------------------------------------------------------- /LcPrint/LcPrintObj.h: -------------------------------------------------------------------------------- 1 | // 2 | // Describe.h 3 | // TPModel 4 | // 5 | // Created by jiangliancheng on 15/11/3. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NSString *describeObj(id object, BOOL circlePrintSuper); 12 | -------------------------------------------------------------------------------- /LcPrint/LcPrintObj.m: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrintObj.m 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/6. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "LcPrintObj.h" 11 | #import 12 | #import "LcPrint.h" 13 | #import "LcStringFromStruct.h" 14 | #import "LcPrintMacro.h" 15 | #import "LcPrintUtility.h" 16 | 17 | static NSMutableArray *stackClassList; 18 | 19 | static NSArray *basicClusterClassList; 20 | static NSArray *basicNormalClassList; 21 | static NSArray *setClassList; 22 | static inline void initClassList(); 23 | 24 | static inline NSString *__describeObj(id object, Class class, BOOL circle); 25 | static inline NSString *describeBasicClass(NSString *classString,id object); 26 | static inline NSString *describeNSValue(NSValue *value); 27 | static inline NSString *describeSet(NSString *setClass,NSSet *list, BOOL circle); 28 | static inline NSString *describeDictionary(NSDictionary *map, BOOL circle); 29 | static inline NSString *describeNSObject(id object, Class class, BOOL circle); 30 | 31 | 32 | NSString *describeObj(id object, BOOL circlePrintSuper) 33 | { 34 | return __describeObj(object, object_getClass(object), circlePrintSuper); 35 | } 36 | 37 | static inline NSString *__describeObj(id object, Class class, BOOL circle) 38 | { 39 | initClassList(); 40 | 41 | if (object == nil) 42 | { 43 | return @"nil"; 44 | } 45 | //基础的类族类型:类族类型都需要使用isKindOfClass:判断 46 | for (NSString *classString in basicClusterClassList) 47 | { 48 | if ([object isKindOfClass:NSClassFromString(classString)]){ 49 | return describeBasicClass(classString,object); 50 | } 51 | } 52 | 53 | //基础的普通类型 54 | if ([basicNormalClassList containsObject:NSStringFromClass(class)]) { 55 | return describeBasicClass(NSStringFromClass(class), object); 56 | } 57 | 58 | //NSValue类型(类族) 59 | if ([object isKindOfClass:[NSValue class]]) { 60 | return describeNSValue(object); 61 | } 62 | 63 | //容器类型(类族) 64 | for (NSString *setClass in setClassList) { 65 | if ([object isKindOfClass:NSClassFromString(setClass)]) { 66 | return describeSet(setClass, object, circle); 67 | } 68 | } 69 | 70 | //字典类型(类族) 71 | if ([object isKindOfClass:[NSDictionary class]]) { 72 | return describeDictionary(object, circle); 73 | } 74 | 75 | //自定义类型 76 | return describeNSObject(object, class, circle); 77 | } 78 | 79 | #pragma mark - handle 80 | 81 | static inline NSString *describeBasicClass(NSString *classString,id object) 82 | { 83 | if ([object isEqual:__lc_unknown_type]) { 84 | return object; 85 | } 86 | return __LcString(@"(%@ *)%@",classString,object); 87 | } 88 | 89 | static inline NSString *describeSet(NSString *setClass,NSSet *list, BOOL circle) 90 | { 91 | NSMutableString *printString = [NSMutableString string]; 92 | [printString appendFormat:@"(%@ *)[",setClass]; 93 | for (id value in list) { 94 | NSString *string = __LcString(@"\n%@",describeObj(value, circle)); 95 | [printString appendString:__lc_tap_string(string)]; 96 | } [printString appendString:@"\n]"]; 97 | return printString; 98 | } 99 | 100 | static inline NSString *describeDictionary(NSDictionary *map, BOOL circle) 101 | { 102 | NSMutableString *printString = [NSMutableString string]; 103 | [printString appendString:@"{"]; 104 | for (id key in map.allKeys) { 105 | NSString *string = __LcString(@"\n%@:%@",key,describeObj(map[key], circle)); 106 | [printString appendString:__lc_tap_string(string)]; 107 | } 108 | [printString appendString:@"\n}"]; 109 | return printString; 110 | } 111 | 112 | static inline NSString *describeNSObject(id object, Class class, BOOL circle) 113 | { 114 | if ([NSObject isSubclassOfClass:class]) { 115 | return [object description]; 116 | } 117 | 118 | if ([stackClassList containsObject:NSStringFromClass(class)]) { 119 | return [object description]; 120 | } 121 | 122 | [stackClassList addObject:NSStringFromClass(class)]; 123 | 124 | NSMutableString *printString = [NSMutableString string]; 125 | [printString appendFormat:@"(%@ *){",class]; 126 | 127 | //循环打印父类 128 | if (circle) { 129 | Class superClass = class_getSuperclass(class); 130 | if (![NSObject isSubclassOfClass:superClass]) { 131 | NSString *string = __LcString(@"\n%@",(__describeObj(object,superClass, circle))); 132 | [printString appendString:__lc_tap_string(string)]; 133 | } 134 | } 135 | 136 | //打印本类的属性 137 | NSArray *names = __lc_property_ivar_name_list(class); 138 | 139 | //如果本类没有属性,并且不打印父类,则直接返回description 140 | if (names.count == 0 && !circle) { 141 | return [object description]; 142 | } 143 | 144 | for (NSString *name in names) { 145 | id value = __lc_value_for_key(object, name); 146 | NSString *string = __LcString(@"\n%@ = %@",name,describeObj(value, circle)); 147 | [printString appendString:__lc_tap_string(string)]; 148 | } 149 | 150 | [printString appendFormat:@"\n}(%@ *)",class]; 151 | 152 | [stackClassList removeObject:NSStringFromClass(class)]; 153 | 154 | return printString; 155 | } 156 | 157 | static inline NSString *describeNSValue(NSValue *value) 158 | { 159 | 160 | #define CheckBasicType(TYPE) \ 161 | if (strcmp(value.objCType, @encode(TYPE)) == 0) { \ 162 | return __LcString(@"(%s)%@",__STRING(TYPE),value); \ 163 | } 164 | 165 | CheckBasicType(short); 166 | CheckBasicType(int); 167 | CheckBasicType(long); 168 | CheckBasicType(long long); 169 | CheckBasicType(float); 170 | CheckBasicType(double); 171 | CheckBasicType(double); 172 | CheckBasicType(BOOL); 173 | CheckBasicType(bool); 174 | CheckBasicType(char); 175 | CheckBasicType(unsigned short); 176 | CheckBasicType(unsigned int); 177 | CheckBasicType(unsigned long); 178 | CheckBasicType(unsigned long long); 179 | CheckBasicType(unsigned char); 180 | 181 | #undef CheckBasicType 182 | 183 | #define CheckStructType(TYPE) \ 184 | if (strcmp(value.objCType, @encode(TYPE)) == 0) { \ 185 | TYPE var; \ 186 | [value getValue:&var]; \ 187 | return __LcString(@"(CFRange)%@",LcStringFrom##TYPE(var)); \ 188 | } 189 | 190 | CheckStructType(CGPoint); 191 | CheckStructType(CGSize); 192 | CheckStructType(CGVector); 193 | CheckStructType(CGRect); 194 | CheckStructType(NSRange); 195 | CheckStructType(CFRange); 196 | CheckStructType(CGAffineTransform); 197 | CheckStructType(CATransform3D); 198 | CheckStructType(UIOffset); 199 | CheckStructType(UIEdgeInsets); 200 | 201 | #undef CheckStructType 202 | 203 | return [value description]; 204 | } 205 | 206 | 207 | #pragma mark - help 208 | 209 | static inline void initClassList() 210 | { 211 | static dispatch_once_t onceToken; 212 | dispatch_once(&onceToken, ^{ 213 | stackClassList = [NSMutableArray array]; 214 | basicClusterClassList = @[@"NSString",@"NSDate",@"UIColor",]; 215 | basicNormalClassList = @[@"UIView",@"UIViewController",@"NSURL",@"UIWindow",@"UILabel",@"UIButton",@"UIActivity",@"UIActivityIndicatorView",@"UIActionSheet",@"UIActivityViewController",@"UIAlertView",@"UIControl",@"UIDevice",@"UIDocument",@"UIEvent",@"UIFont",@"UIImage",@"UINib",@"UIPageControl",@"UIPickerView",@"UIScreen",@"UITableViewCell",@"UITableView"]; 216 | setClassList = @[@"NSArray",@"NSSet",@"NSOrderedSet",@"NSPointerArray"]; 217 | }); 218 | 219 | return; 220 | } 221 | 222 | 223 | 224 | 225 | -------------------------------------------------------------------------------- /LcPrint/LcPrintUtility.h: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrintUtility.h 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/8. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | extern NSArray *__lc_property_ivar_name_list(Class class); 12 | extern NSArray *__lc_property_name_list(Class class); 13 | extern NSArray *__lc_ivar_name_list(Class class); 14 | extern NSArray *__lc_method_name_list(Class class); 15 | extern NSString *__lc_tap_string(NSString *string); 16 | 17 | extern id __lc_value_for_key(id object, NSString *key); 18 | extern NSString *__lc_unknown_type; 19 | -------------------------------------------------------------------------------- /LcPrint/LcPrintUtility.m: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrintUtility.m 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/8. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import "LcPrintUtility.h" 10 | #import 11 | #import "LcPrintMacro.h" 12 | #import 13 | 14 | static inline NSString *propertyNameFromIvarName(NSString *name); 15 | static inline id __lc_custom_value_for_key(id object, NSString *key); 16 | static inline const char *__lc_useful_type_from_ivar_type(const char *ivarType); 17 | static inline const BOOL __lc_has_contain_char(char *string, char c); 18 | 19 | NSString *__lc_unknown_type = @"unknown type"; 20 | 21 | NSArray *__lc_ivar_name_list(Class class) 22 | { 23 | NSMutableArray *nameList = [NSMutableArray array]; 24 | uint count; 25 | Ivar *ivarList = class_copyIvarList(class, &count); 26 | for (int i = 0; i < count; i++) { 27 | Ivar ivar = ivarList[i]; 28 | const char *name = ivar_getName(ivar); 29 | [nameList addObject:@(name)]; 30 | } 31 | return nameList; 32 | } 33 | 34 | NSArray *__lc_property_name_list(Class class) 35 | { 36 | NSMutableArray *nameList = [NSMutableArray array]; 37 | uint count; 38 | objc_property_t *propertyList = class_copyPropertyList(class, &count); 39 | for (int i = 0; i < count; i++) { 40 | objc_property_t property = propertyList[i]; 41 | const char *name = property_getName(property); 42 | [nameList addObject:@(name)]; 43 | } 44 | return nameList; 45 | } 46 | 47 | NSArray *__lc_property_ivar_name_list(Class class) 48 | { 49 | NSArray *propertyList = __lc_property_name_list(class); 50 | NSArray *ivarList = __lc_ivar_name_list(class); 51 | 52 | NSMutableArray *nameList = [NSMutableArray array]; 53 | //添加与property不重复的ivar 54 | for (NSString *name in ivarList) { 55 | NSString *propertyName = propertyNameFromIvarName(name); 56 | if ([propertyList containsObject:propertyName]) { 57 | continue; 58 | } 59 | [nameList addObject:name]; 60 | } 61 | 62 | [nameList addObjectsFromArray:propertyList]; 63 | return nameList; 64 | } 65 | 66 | NSArray *__lc_method_name_list(Class class) 67 | { 68 | NSMutableArray *selList = [NSMutableArray array]; 69 | uint count; 70 | Method *methodList = class_copyMethodList(class, &count); 71 | for (int i = 0; i < count; i++) { 72 | Method method = methodList[i]; 73 | SEL sel = method_getName(method); 74 | [selList addObject:NSStringFromSelector(sel)]; 75 | } 76 | return selList; 77 | } 78 | 79 | NSString *__lc_tap_string(NSString *string) 80 | { 81 | return [string stringByReplacingOccurrencesOfString:@"\n" withString:@"\n\t"]; 82 | } 83 | 84 | id __lc_value_for_key(id object, NSString *key) 85 | { 86 | id value; 87 | 88 | #if __USE_SYSTEM_KVO 89 | @try { 90 | value = [object valueForKey:key]; 91 | } 92 | @catch (NSException *exception) { 93 | return nil; 94 | } 95 | #else 96 | 97 | value = __lc_custom_value_for_key(object, key); 98 | #endif 99 | return value; 100 | } 101 | 102 | #pragma mark - inline 103 | 104 | //type 类型参见https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html 105 | 106 | #define GET_VALUE_FROM(TYPE) \ 107 | if (strcmp(type, @encode(TYPE)) == 0) { \ 108 | value = @(*(TYPE*)var); \ 109 | goto FINISH; \ 110 | } 111 | 112 | 113 | static inline id __lc_value_for_sel(id object, SEL sel) 114 | { 115 | NSMethodSignature *sig = [object methodSignatureForSelector:sel]; 116 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sig]; 117 | [invocation setSelector:sel]; 118 | [invocation invokeWithTarget:object]; 119 | [invocation retainArguments]; 120 | id value; 121 | const char *type = sig.methodReturnType; 122 | if (strcmp(type, @encode(void)) == 0) { 123 | return nil; 124 | } 125 | 126 | //unknown type 127 | if (__lc_has_contain_char((char*)type, '?')|| 128 | __lc_has_contain_char((char*)type, ':')|| 129 | __lc_has_contain_char((char*)type, 'b')|| 130 | __lc_has_contain_char((char*)type, '(')|| 131 | __lc_has_contain_char((char*)type, '[')) 132 | { 133 | return __lc_unknown_type; 134 | } 135 | 136 | if (strcmp(type, @encode(id)) == 0|| 137 | strcmp(type, @encode(Class)) == 0) 138 | { 139 | //使用NSInvocation的参数都是__unsafe_unretained类型,这里直接使用value也不会retain,导致ARC错误 140 | __unsafe_unretained id buffer; 141 | [invocation getReturnValue:&buffer]; 142 | value = buffer; 143 | } 144 | else 145 | { 146 | NSUInteger length = [sig methodReturnLength]; 147 | void *var = (void *)malloc(length); 148 | [invocation getReturnValue:var]; 149 | 150 | GET_VALUE_FROM(char); 151 | GET_VALUE_FROM(int); 152 | GET_VALUE_FROM(short); 153 | GET_VALUE_FROM(long); 154 | GET_VALUE_FROM(long long); 155 | GET_VALUE_FROM(unsigned char); 156 | GET_VALUE_FROM(uint); 157 | GET_VALUE_FROM(ushort); 158 | GET_VALUE_FROM(unsigned long); 159 | GET_VALUE_FROM(unsigned long long); 160 | GET_VALUE_FROM(float); 161 | GET_VALUE_FROM(double); 162 | GET_VALUE_FROM(BOOL); 163 | GET_VALUE_FROM(bool); 164 | 165 | value = [NSValue value:var withObjCType:type]; 166 | free(var); 167 | } 168 | 169 | FINISH: 170 | return value; 171 | } 172 | 173 | static inline id __lc_value_for_ivar(id object, Ivar ivar) 174 | { 175 | const char *ivarType = ivar_getTypeEncoding(ivar); 176 | const char *type = __lc_useful_type_from_ivar_type(ivarType); 177 | 178 | //void 179 | if (strcmp(type, @encode(void)) == 0) { 180 | return nil; 181 | } 182 | 183 | //unknown type 184 | if (__lc_has_contain_char((char*)type, '?')|| 185 | __lc_has_contain_char((char*)type, ':')|| 186 | __lc_has_contain_char((char*)type, 'b')|| 187 | __lc_has_contain_char((char*)type, '(')|| 188 | __lc_has_contain_char((char*)type, '[')) 189 | { 190 | return __lc_unknown_type; 191 | } 192 | 193 | 194 | //id 195 | if (strcmp(type, @encode(id)) == 0) { 196 | return object_getIvar(object, ivar); 197 | } 198 | 199 | //NSValue or NSNumber 200 | id value; 201 | ptrdiff_t offset = ivar_getOffset(ivar); 202 | void *var = (__bridge void*)object + offset; 203 | 204 | GET_VALUE_FROM(char); 205 | GET_VALUE_FROM(int); 206 | GET_VALUE_FROM(short); 207 | GET_VALUE_FROM(long); 208 | GET_VALUE_FROM(long long); 209 | GET_VALUE_FROM(unsigned char); 210 | GET_VALUE_FROM(uint); 211 | GET_VALUE_FROM(ushort); 212 | GET_VALUE_FROM(unsigned long); 213 | GET_VALUE_FROM(unsigned long long); 214 | GET_VALUE_FROM(float); 215 | GET_VALUE_FROM(double); 216 | GET_VALUE_FROM(BOOL); 217 | GET_VALUE_FROM(bool); 218 | 219 | value = [NSValue value:var withObjCType:type]; 220 | FINISH: 221 | 222 | return value; 223 | } 224 | 225 | #undef GET_VALUE_FROM 226 | 227 | static inline id __lc_custom_value_for_key(id object, NSString *key) 228 | { 229 | id value = nil; 230 | 231 | SEL sel = NSSelectorFromString(key); 232 | if ([object respondsToSelector:sel]) { 233 | value = __lc_value_for_sel(object, sel); 234 | } 235 | 236 | Class class = object_getClass(object); 237 | 238 | Ivar ivar = class_getInstanceVariable(class, [key UTF8String]); 239 | if (!ivar) { 240 | ivar = class_getInstanceVariable(class, [__LcString(@"_%@",key) UTF8String]); 241 | } 242 | if (ivar) { 243 | value = __lc_value_for_ivar(object, ivar); 244 | } 245 | 246 | return value; 247 | } 248 | 249 | 250 | static inline NSString *propertyNameFromIvarName(NSString *name) 251 | { 252 | return [name stringByReplacingOccurrencesOfString:@"_" 253 | withString:@"" 254 | options:0 255 | range:NSMakeRange(0, 1)]; 256 | } 257 | 258 | //ivar_getTypeEncoding获取的type会添加很多其他信息,不能直接使用,所以需要将这些信息去掉。这些信息一般都存放在""中 259 | static inline const char *__lc_useful_type_from_ivar_type(const char *ivarType) 260 | { 261 | NSMutableString *string = [NSMutableString stringWithFormat:@"%s",ivarType]; 262 | 263 | //将双引号中间的东西去掉 264 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\"[^\"]*\"" options:0 error:NULL]; 265 | NSArray *results = [regex matchesInString:string options:0 range:NSMakeRange(0, string.length)]; 266 | 267 | for (int i = (int)results.count - 1; i >= 0; i--) { 268 | NSTextCheckingResult *result = results[i]; 269 | [string deleteCharactersInRange:result.range]; 270 | } 271 | const char *type = [string UTF8String]; 272 | return type; 273 | } 274 | 275 | 276 | static inline const BOOL __lc_has_contain_char(char *string, char c) 277 | { 278 | NSRange range = [__LcString(@"%s",string) rangeOfString:__LcString(@"%c",c)]; 279 | if (range.length > 0) { 280 | return YES; 281 | } 282 | return NO; 283 | } 284 | 285 | 286 | 287 | 288 | 289 | 290 | -------------------------------------------------------------------------------- /LcPrint/LcPrintVar.h: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrintVar.h 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/5. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | extern NSString *describeVar(const char *type, ...); 12 | 13 | -------------------------------------------------------------------------------- /LcPrint/LcPrintVar.m: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrintVar.m 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/6. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "LcPrintVar.h" 11 | #import "LcStringFromStruct.h" 12 | #import "LcPrint.h" 13 | #import "LcPrintMacro.h" 14 | 15 | 16 | #pragma clang diagnostic push 17 | #pragma clang diagnostic ignored "-Wvarargs" 18 | 19 | 20 | #define checkNumType(NumType) \ 21 | if (strcmp(type, @encode(NumType)) == 0) { \ 22 | NumType param = (NumType)va_arg(variable_param_list, NumType); \ 23 | return __LcString(@"(%s)%@",__STRING(NumType),@(param)); \ 24 | } 25 | 26 | #define checkStructType(StructType) \ 27 | if (strcmp(type, @encode(StructType)) == 0) { \ 28 | StructType param = va_arg(variable_param_list, StructType); \ 29 | return __LcString(@"(%s)%@",__STRING(StructType),LcStringFrom##StructType(param)); \ 30 | } 31 | 32 | 33 | static inline NSString *__describeVar(const char *type, va_list variable_param_list); 34 | 35 | NSString *describeVar(const char *type, ...) 36 | { 37 | va_list variable_param_list; 38 | va_start(variable_param_list, type); 39 | 40 | if (strcmp(type, @encode(id)) == 0) { 41 | id obj = va_arg(variable_param_list, id); 42 | return describeObj(obj, NO); 43 | } 44 | 45 | return __describeVar(type, variable_param_list); 46 | } 47 | 48 | static inline NSString *__describeVar(const char *type, va_list variable_param_list) 49 | { 50 | if (strcmp(type, @encode(BOOL)) == 0) { 51 | BOOL param = va_arg(variable_param_list, BOOL); 52 | return __LcString(@"(BOOL)%@",param?@"YES":@"NO"); 53 | } 54 | if (strcmp(type, @encode(char)) == 0) { 55 | char param = va_arg(variable_param_list, char); 56 | return __LcString(@"(char)'%c'",param); 57 | } 58 | if (strcmp(type, @encode(unsigned char)) == 0) { 59 | unsigned char param = va_arg(variable_param_list, unsigned char); 60 | return __LcString(@"(unsigned char)'%c'",param); 61 | } 62 | if (strcmp(type, @encode(char *)) == 0) { 63 | char *param = va_arg(variable_param_list, char *); 64 | return __LcString(@"(char *)\"%s\"",param); 65 | } 66 | checkNumType(int); 67 | checkNumType(short); 68 | checkNumType(long); 69 | checkNumType(long long); 70 | checkNumType(unsigned int); 71 | checkNumType(unsigned short); 72 | checkNumType(unsigned long); 73 | checkNumType(unsigned long long); 74 | checkNumType(float); 75 | checkNumType(double); 76 | checkNumType(char *); 77 | 78 | checkStructType(Class); 79 | checkStructType(CGPoint); 80 | checkStructType(CGSize); 81 | checkStructType(CGVector); 82 | checkStructType(CGRect); 83 | checkStructType(NSRange); 84 | checkStructType(CFRange); 85 | checkStructType(CGAffineTransform); 86 | checkStructType(CATransform3D); 87 | checkStructType(UIOffset); 88 | checkStructType(UIEdgeInsets); 89 | 90 | void * param = (void *)va_arg(variable_param_list, void *); 91 | return [NSString stringWithFormat:@"%p", param]; 92 | } 93 | 94 | #undef checkNumType 95 | #undef checkStructType 96 | 97 | #pragma clang diagnostic pop 98 | -------------------------------------------------------------------------------- /LcPrint/LcPrintViews.h: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrintAdvance.h 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/7. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | extern NSString *describeViews(UIView *view); 14 | 15 | -------------------------------------------------------------------------------- /LcPrint/LcPrintViews.m: -------------------------------------------------------------------------------- 1 | // 2 | // LcPrintAdvance.m 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/7. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import "LcPrintViews.h" 10 | #import "LcPrintMacro.h" 11 | 12 | 13 | static inline NSString *__describeViews(UIView *view, NSUInteger level); 14 | 15 | NSString *describeViews(UIView *view) 16 | { 17 | return __describeViews(view, 0); 18 | } 19 | 20 | static inline NSString *tapString(NSString *string, NSUInteger tapNum) 21 | { 22 | if (string.length == 0) { 23 | return @""; 24 | } 25 | 26 | NSMutableString *mutableString = [NSMutableString stringWithString:string]; 27 | for (int i = 0; i <= tapNum; i++) { 28 | [mutableString insertString:@"\t" atIndex:0]; 29 | } 30 | 31 | return mutableString; 32 | } 33 | 34 | static inline NSString *__describeViews(UIView *view, NSUInteger level) 35 | { 36 | NSMutableString *describe = [NSMutableString stringWithFormat:@"%tu 💙",level]; 37 | [describe appendString:tapString(view.description, level)]; 38 | NSUInteger subLevel = level + 1; 39 | for (UIView *subView in view.subviews) { 40 | [describe appendFormat:@"\n%@",__describeViews(subView, subLevel)]; 41 | } 42 | return describe; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /LcPrint/LcStringFromStruct.h: -------------------------------------------------------------------------------- 1 | // 2 | // LcStringFromStruct.h 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/5. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | extern NSString *LcStringFromCATransform3D(CATransform3D transform); 13 | extern NSString *LcStringFromCGPoint(CGPoint var); 14 | extern NSString *LcStringFromCGSize(CGSize var); 15 | extern NSString *LcStringFromCGVector(CGVector var); 16 | extern NSString *LcStringFromCGAffineTransform(CGAffineTransform var); 17 | extern NSString *LcStringFromUIOffset(UIOffset var); 18 | extern NSString *LcStringFromUIEdgeInsets(UIEdgeInsets var); 19 | extern NSString *LcStringFromNSRange(NSRange range); 20 | extern NSString *LcStringFromCFRange(CFRange range); 21 | extern NSString *LcStringFromCGRect(CGRect var); 22 | extern NSString *LcStringFromClass(Class class); 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /LcPrint/LcStringFromStruct.m: -------------------------------------------------------------------------------- 1 | // 2 | // LcStringFromStruct.m 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/5. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import "LcStringFromStruct.h" 10 | #import "LcPrintMacro.h" 11 | 12 | NSString *LcStringFromCATransform3D(CATransform3D transform) 13 | { 14 | NSString *string1 = __LcString(@"(\n\tm11 = %g, m12 = %g, m13 = %g, m14 = %g",transform.m11,transform.m12,transform.m13,transform.m14); 15 | NSString *string2 = __LcString(@"\n\tm21 = %g, m22 = %g, m23 = %g, m24 = %g",transform.m21,transform.m22,transform.m23,transform.m24); 16 | NSString *string3 = __LcString(@"\n\tm31 = %g, m32 = %g, m33 = %g, m34 = %g",transform.m31,transform.m32,transform.m33,transform.m34); 17 | NSString *string4 = __LcString(@"\n\tm41 = %g, m42 = %g, m43 = %g, m44 = %g\n)",transform.m31,transform.m32,transform.m33,transform.m34); 18 | return __LcString(@"%@%@%@%@",string1,string2,string3,string4); 19 | } 20 | 21 | NSString *LcStringFromCGPoint(CGPoint var) 22 | { 23 | return __LcString(@"(x = %g, y = %g)",var.x,var.y); 24 | } 25 | 26 | NSString *LcStringFromCGSize(CGSize var) 27 | { 28 | return __LcString(@"(width = %g, height = %g)",var.width,var.height); 29 | } 30 | 31 | NSString *LcStringFromCGVector(CGVector var) 32 | { 33 | return __LcString(@"(dx = %g, dy = %g)",var.dx,var.dy); 34 | } 35 | 36 | NSString *LcStringFromCGAffineTransform(CGAffineTransform var) 37 | { 38 | NSString *string1 = __LcString(@"(\n\ta = %g, b = %g, c = %g, d = %g",var.a,var.b,var.c,var.d); 39 | NSString *string2 = __LcString(@"\n\ttx = %g, ty = %g\n)",var.tx,var.ty); 40 | return __LcString(@"%@%@",string1,string2); 41 | } 42 | 43 | NSString *LcStringFromUIOffset(UIOffset var) 44 | { 45 | return __LcString(@"(horizontal = %g, vertical = %g)",var.horizontal,var.vertical); 46 | } 47 | 48 | NSString *LcStringFromUIEdgeInsets(UIEdgeInsets var) 49 | { 50 | return __LcString(@"(top = %g, left = %g, bottom = %g, right = %g)", 51 | var.top,var.left,var.bottom,var.right); 52 | } 53 | 54 | NSString *LcStringFromCGRect(CGRect var) 55 | { 56 | return __LcString(@"(\n\tCGPoint = %@\n\tCGSize = %@\n)",LcStringFromCGPoint(var.origin),LcStringFromCGSize(var.size)); 57 | } 58 | 59 | NSString *LcStringFromNSRange(NSRange range) 60 | { 61 | return __LcString(@"(location = %tu, length = %tu)",range.location,range.length); 62 | } 63 | 64 | NSString *LcStringFromCFRange(CFRange range) 65 | { 66 | return __LcString(@"(location = %lu, length = %lu)",range.location,range.length); 67 | } 68 | 69 | NSString *LcStringFromClass(Class class) 70 | { 71 | return NSStringFromClass(class); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 750FD9741BEC875F00BCFC4F /* LcStringFromStruct.m in Sources */ = {isa = PBXBuildFile; fileRef = 750FD9731BEC875F00BCFC4F /* LcStringFromStruct.m */; }; 11 | 7550646A1BE998B20045DAEB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 755064691BE998B20045DAEB /* main.m */; }; 12 | 7550646D1BE998B20045DAEB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7550646C1BE998B20045DAEB /* AppDelegate.m */; }; 13 | 755064701BE998B20045DAEB /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7550646F1BE998B20045DAEB /* ViewController.m */; }; 14 | 755064731BE998B20045DAEB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 755064711BE998B20045DAEB /* Main.storyboard */; }; 15 | 755064751BE998B20045DAEB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 755064741BE998B20045DAEB /* Assets.xcassets */; }; 16 | 755064781BE998B20045DAEB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 755064761BE998B20045DAEB /* LaunchScreen.storyboard */; }; 17 | 755064851BE9F5F80045DAEB /* Model.m in Sources */ = {isa = PBXBuildFile; fileRef = 755064841BE9F5F80045DAEB /* Model.m */; }; 18 | 757544681BEC9854002ABDF8 /* LcPrintObj.m in Sources */ = {isa = PBXBuildFile; fileRef = 757544671BEC9854002ABDF8 /* LcPrintObj.m */; }; 19 | 7575446A1BEC98C8002ABDF8 /* LcPrintVar.m in Sources */ = {isa = PBXBuildFile; fileRef = 757544691BEC98C8002ABDF8 /* LcPrintVar.m */; }; 20 | 757D80571BEF131300F35430 /* LcPrintInner.m in Sources */ = {isa = PBXBuildFile; fileRef = 757D80561BEF131300F35430 /* LcPrintInner.m */; }; 21 | 757D805A1BEF1BA300F35430 /* LcPrintUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = 757D80591BEF1BA300F35430 /* LcPrintUtility.m */; }; 22 | 7599B5DC1BEDCFBC00FFA794 /* LcPrintViews.m in Sources */ = {isa = PBXBuildFile; fileRef = 7599B5DB1BEDCFBC00FFA794 /* LcPrintViews.m */; }; 23 | 75DCD96E1BED9F370065D1CD /* LcPrint+LLDB.m in Sources */ = {isa = PBXBuildFile; fileRef = 75DCD96D1BED9F370065D1CD /* LcPrint+LLDB.m */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | 750FD96F1BEC875F00BCFC4F /* LcPrint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LcPrint.h; sourceTree = ""; }; 28 | 750FD9701BEC875F00BCFC4F /* LcPrintObj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LcPrintObj.h; sourceTree = ""; }; 29 | 750FD9711BEC875F00BCFC4F /* LcPrintVar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LcPrintVar.h; sourceTree = ""; }; 30 | 750FD9721BEC875F00BCFC4F /* LcStringFromStruct.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LcStringFromStruct.h; sourceTree = ""; }; 31 | 750FD9731BEC875F00BCFC4F /* LcStringFromStruct.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LcStringFromStruct.m; sourceTree = ""; }; 32 | 755064651BE998B20045DAEB /* PrintValueSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PrintValueSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 755064691BE998B20045DAEB /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 34 | 7550646B1BE998B20045DAEB /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | 7550646C1BE998B20045DAEB /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | 7550646E1BE998B20045DAEB /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 37 | 7550646F1BE998B20045DAEB /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 38 | 755064721BE998B20045DAEB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 39 | 755064741BE998B20045DAEB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 40 | 755064771BE998B20045DAEB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 41 | 755064791BE998B20045DAEB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | 755064831BE9F5F80045DAEB /* Model.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Model.h; sourceTree = ""; }; 43 | 755064841BE9F5F80045DAEB /* Model.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Model.m; sourceTree = ""; }; 44 | 757544671BEC9854002ABDF8 /* LcPrintObj.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LcPrintObj.m; sourceTree = ""; }; 45 | 757544691BEC98C8002ABDF8 /* LcPrintVar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LcPrintVar.m; sourceTree = ""; }; 46 | 757D80551BEF131300F35430 /* LcPrintInner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LcPrintInner.h; sourceTree = ""; }; 47 | 757D80561BEF131300F35430 /* LcPrintInner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LcPrintInner.m; sourceTree = ""; }; 48 | 757D80581BEF1BA300F35430 /* LcPrintUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LcPrintUtility.h; sourceTree = ""; }; 49 | 757D80591BEF1BA300F35430 /* LcPrintUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LcPrintUtility.m; sourceTree = ""; }; 50 | 7599B5DB1BEDCFBC00FFA794 /* LcPrintViews.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LcPrintViews.m; sourceTree = ""; }; 51 | 7599B5DD1BEDCFCD00FFA794 /* LcPrintViews.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LcPrintViews.h; sourceTree = ""; }; 52 | 7599B5E21BEE036C00FFA794 /* LcPrintMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LcPrintMacro.h; sourceTree = ""; }; 53 | 75DCD96C1BED9F080065D1CD /* LcPrint+LLDB.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "LcPrint+LLDB.h"; sourceTree = ""; }; 54 | 75DCD96D1BED9F370065D1CD /* LcPrint+LLDB.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "LcPrint+LLDB.m"; sourceTree = ""; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | 755064621BE998B20045DAEB /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | /* End PBXFrameworksBuildPhase section */ 66 | 67 | /* Begin PBXGroup section */ 68 | 750FD96E1BEC875F00BCFC4F /* LcPrint */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 750FD96F1BEC875F00BCFC4F /* LcPrint.h */, 72 | 75DCD96C1BED9F080065D1CD /* LcPrint+LLDB.h */, 73 | 75DCD96D1BED9F370065D1CD /* LcPrint+LLDB.m */, 74 | 7599B5E21BEE036C00FFA794 /* LcPrintMacro.h */, 75 | 7599B5DD1BEDCFCD00FFA794 /* LcPrintViews.h */, 76 | 7599B5DB1BEDCFBC00FFA794 /* LcPrintViews.m */, 77 | 757D80551BEF131300F35430 /* LcPrintInner.h */, 78 | 757D80561BEF131300F35430 /* LcPrintInner.m */, 79 | 757D80581BEF1BA300F35430 /* LcPrintUtility.h */, 80 | 757D80591BEF1BA300F35430 /* LcPrintUtility.m */, 81 | 750FD9701BEC875F00BCFC4F /* LcPrintObj.h */, 82 | 757544671BEC9854002ABDF8 /* LcPrintObj.m */, 83 | 750FD9711BEC875F00BCFC4F /* LcPrintVar.h */, 84 | 757544691BEC98C8002ABDF8 /* LcPrintVar.m */, 85 | 750FD9721BEC875F00BCFC4F /* LcStringFromStruct.h */, 86 | 750FD9731BEC875F00BCFC4F /* LcStringFromStruct.m */, 87 | ); 88 | name = LcPrint; 89 | path = ../LcPrint; 90 | sourceTree = ""; 91 | }; 92 | 7550645C1BE998B20045DAEB = { 93 | isa = PBXGroup; 94 | children = ( 95 | 750FD96E1BEC875F00BCFC4F /* LcPrint */, 96 | 755064671BE998B20045DAEB /* PrintValueSample */, 97 | 755064661BE998B20045DAEB /* Products */, 98 | ); 99 | sourceTree = ""; 100 | }; 101 | 755064661BE998B20045DAEB /* Products */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 755064651BE998B20045DAEB /* PrintValueSample.app */, 105 | ); 106 | name = Products; 107 | sourceTree = ""; 108 | }; 109 | 755064671BE998B20045DAEB /* PrintValueSample */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 7550646B1BE998B20045DAEB /* AppDelegate.h */, 113 | 7550646C1BE998B20045DAEB /* AppDelegate.m */, 114 | 755064831BE9F5F80045DAEB /* Model.h */, 115 | 755064841BE9F5F80045DAEB /* Model.m */, 116 | 7550646E1BE998B20045DAEB /* ViewController.h */, 117 | 7550646F1BE998B20045DAEB /* ViewController.m */, 118 | 755064711BE998B20045DAEB /* Main.storyboard */, 119 | 755064741BE998B20045DAEB /* Assets.xcassets */, 120 | 755064761BE998B20045DAEB /* LaunchScreen.storyboard */, 121 | 755064791BE998B20045DAEB /* Info.plist */, 122 | 755064681BE998B20045DAEB /* Supporting Files */, 123 | ); 124 | path = PrintValueSample; 125 | sourceTree = ""; 126 | }; 127 | 755064681BE998B20045DAEB /* Supporting Files */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 755064691BE998B20045DAEB /* main.m */, 131 | ); 132 | name = "Supporting Files"; 133 | sourceTree = ""; 134 | }; 135 | /* End PBXGroup section */ 136 | 137 | /* Begin PBXNativeTarget section */ 138 | 755064641BE998B20045DAEB /* PrintValueSample */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = 7550647C1BE998B20045DAEB /* Build configuration list for PBXNativeTarget "PrintValueSample" */; 141 | buildPhases = ( 142 | 755064611BE998B20045DAEB /* Sources */, 143 | 755064621BE998B20045DAEB /* Frameworks */, 144 | 755064631BE998B20045DAEB /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | ); 150 | name = PrintValueSample; 151 | productName = PrintValueSample; 152 | productReference = 755064651BE998B20045DAEB /* PrintValueSample.app */; 153 | productType = "com.apple.product-type.application"; 154 | }; 155 | /* End PBXNativeTarget section */ 156 | 157 | /* Begin PBXProject section */ 158 | 7550645D1BE998B20045DAEB /* Project object */ = { 159 | isa = PBXProject; 160 | attributes = { 161 | LastUpgradeCheck = 0710; 162 | ORGANIZATIONNAME = jiangliancheng; 163 | TargetAttributes = { 164 | 755064641BE998B20045DAEB = { 165 | CreatedOnToolsVersion = 7.1; 166 | }; 167 | }; 168 | }; 169 | buildConfigurationList = 755064601BE998B20045DAEB /* Build configuration list for PBXProject "PrintValueSample" */; 170 | compatibilityVersion = "Xcode 3.2"; 171 | developmentRegion = English; 172 | hasScannedForEncodings = 0; 173 | knownRegions = ( 174 | en, 175 | Base, 176 | ); 177 | mainGroup = 7550645C1BE998B20045DAEB; 178 | productRefGroup = 755064661BE998B20045DAEB /* Products */; 179 | projectDirPath = ""; 180 | projectRoot = ""; 181 | targets = ( 182 | 755064641BE998B20045DAEB /* PrintValueSample */, 183 | ); 184 | }; 185 | /* End PBXProject section */ 186 | 187 | /* Begin PBXResourcesBuildPhase section */ 188 | 755064631BE998B20045DAEB /* Resources */ = { 189 | isa = PBXResourcesBuildPhase; 190 | buildActionMask = 2147483647; 191 | files = ( 192 | 755064781BE998B20045DAEB /* LaunchScreen.storyboard in Resources */, 193 | 755064751BE998B20045DAEB /* Assets.xcassets in Resources */, 194 | 755064731BE998B20045DAEB /* Main.storyboard in Resources */, 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | }; 198 | /* End PBXResourcesBuildPhase section */ 199 | 200 | /* Begin PBXSourcesBuildPhase section */ 201 | 755064611BE998B20045DAEB /* Sources */ = { 202 | isa = PBXSourcesBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | 757544681BEC9854002ABDF8 /* LcPrintObj.m in Sources */, 206 | 7575446A1BEC98C8002ABDF8 /* LcPrintVar.m in Sources */, 207 | 755064701BE998B20045DAEB /* ViewController.m in Sources */, 208 | 7550646D1BE998B20045DAEB /* AppDelegate.m in Sources */, 209 | 7550646A1BE998B20045DAEB /* main.m in Sources */, 210 | 750FD9741BEC875F00BCFC4F /* LcStringFromStruct.m in Sources */, 211 | 75DCD96E1BED9F370065D1CD /* LcPrint+LLDB.m in Sources */, 212 | 757D80571BEF131300F35430 /* LcPrintInner.m in Sources */, 213 | 7599B5DC1BEDCFBC00FFA794 /* LcPrintViews.m in Sources */, 214 | 757D805A1BEF1BA300F35430 /* LcPrintUtility.m in Sources */, 215 | 755064851BE9F5F80045DAEB /* Model.m in Sources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXSourcesBuildPhase section */ 220 | 221 | /* Begin PBXVariantGroup section */ 222 | 755064711BE998B20045DAEB /* Main.storyboard */ = { 223 | isa = PBXVariantGroup; 224 | children = ( 225 | 755064721BE998B20045DAEB /* Base */, 226 | ); 227 | name = Main.storyboard; 228 | sourceTree = ""; 229 | }; 230 | 755064761BE998B20045DAEB /* LaunchScreen.storyboard */ = { 231 | isa = PBXVariantGroup; 232 | children = ( 233 | 755064771BE998B20045DAEB /* Base */, 234 | ); 235 | name = LaunchScreen.storyboard; 236 | sourceTree = ""; 237 | }; 238 | /* End PBXVariantGroup section */ 239 | 240 | /* Begin XCBuildConfiguration section */ 241 | 7550647A1BE998B20045DAEB /* Debug */ = { 242 | isa = XCBuildConfiguration; 243 | buildSettings = { 244 | ALWAYS_SEARCH_USER_PATHS = NO; 245 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 246 | CLANG_CXX_LIBRARY = "libc++"; 247 | CLANG_ENABLE_MODULES = YES; 248 | CLANG_ENABLE_OBJC_ARC = YES; 249 | CLANG_WARN_BOOL_CONVERSION = YES; 250 | CLANG_WARN_CONSTANT_CONVERSION = YES; 251 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 252 | CLANG_WARN_EMPTY_BODY = YES; 253 | CLANG_WARN_ENUM_CONVERSION = YES; 254 | CLANG_WARN_INT_CONVERSION = YES; 255 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 256 | CLANG_WARN_UNREACHABLE_CODE = YES; 257 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 258 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 259 | COPY_PHASE_STRIP = NO; 260 | DEBUG_INFORMATION_FORMAT = dwarf; 261 | ENABLE_STRICT_OBJC_MSGSEND = YES; 262 | ENABLE_TESTABILITY = YES; 263 | GCC_C_LANGUAGE_STANDARD = gnu99; 264 | GCC_DYNAMIC_NO_PIC = NO; 265 | GCC_NO_COMMON_BLOCKS = YES; 266 | GCC_OPTIMIZATION_LEVEL = 0; 267 | GCC_PREPROCESSOR_DEFINITIONS = ( 268 | "DEBUG=1", 269 | "$(inherited)", 270 | ); 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 278 | MTL_ENABLE_DEBUG_INFO = YES; 279 | ONLY_ACTIVE_ARCH = YES; 280 | SDKROOT = iphoneos; 281 | }; 282 | name = Debug; 283 | }; 284 | 7550647B1BE998B20045DAEB /* Release */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ALWAYS_SEARCH_USER_PATHS = NO; 288 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 289 | CLANG_CXX_LIBRARY = "libc++"; 290 | CLANG_ENABLE_MODULES = YES; 291 | CLANG_ENABLE_OBJC_ARC = YES; 292 | CLANG_WARN_BOOL_CONVERSION = YES; 293 | CLANG_WARN_CONSTANT_CONVERSION = YES; 294 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 295 | CLANG_WARN_EMPTY_BODY = YES; 296 | CLANG_WARN_ENUM_CONVERSION = YES; 297 | CLANG_WARN_INT_CONVERSION = YES; 298 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 299 | CLANG_WARN_UNREACHABLE_CODE = YES; 300 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 301 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 302 | COPY_PHASE_STRIP = NO; 303 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 304 | ENABLE_NS_ASSERTIONS = NO; 305 | ENABLE_STRICT_OBJC_MSGSEND = YES; 306 | GCC_C_LANGUAGE_STANDARD = gnu99; 307 | GCC_NO_COMMON_BLOCKS = YES; 308 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 309 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 310 | GCC_WARN_UNDECLARED_SELECTOR = YES; 311 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 312 | GCC_WARN_UNUSED_FUNCTION = YES; 313 | GCC_WARN_UNUSED_VARIABLE = YES; 314 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 315 | MTL_ENABLE_DEBUG_INFO = NO; 316 | SDKROOT = iphoneos; 317 | VALIDATE_PRODUCT = YES; 318 | }; 319 | name = Release; 320 | }; 321 | 7550647D1BE998B20045DAEB /* Debug */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 325 | CLANG_ENABLE_MODULES = YES; 326 | INFOPLIST_FILE = PrintValueSample/Info.plist; 327 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 328 | PRODUCT_BUNDLE_IDENTIFIER = com.liancheng.PrintValueSample; 329 | PRODUCT_NAME = "$(TARGET_NAME)"; 330 | SWIFT_OBJC_BRIDGING_HEADER = "../printValue/PrintValueSample-Bridging-Header.h"; 331 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 332 | }; 333 | name = Debug; 334 | }; 335 | 7550647E1BE998B20045DAEB /* Release */ = { 336 | isa = XCBuildConfiguration; 337 | buildSettings = { 338 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 339 | CLANG_ENABLE_MODULES = YES; 340 | INFOPLIST_FILE = PrintValueSample/Info.plist; 341 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 342 | PRODUCT_BUNDLE_IDENTIFIER = com.liancheng.PrintValueSample; 343 | PRODUCT_NAME = "$(TARGET_NAME)"; 344 | SWIFT_OBJC_BRIDGING_HEADER = "../printValue/PrintValueSample-Bridging-Header.h"; 345 | }; 346 | name = Release; 347 | }; 348 | /* End XCBuildConfiguration section */ 349 | 350 | /* Begin XCConfigurationList section */ 351 | 755064601BE998B20045DAEB /* Build configuration list for PBXProject "PrintValueSample" */ = { 352 | isa = XCConfigurationList; 353 | buildConfigurations = ( 354 | 7550647A1BE998B20045DAEB /* Debug */, 355 | 7550647B1BE998B20045DAEB /* Release */, 356 | ); 357 | defaultConfigurationIsVisible = 0; 358 | defaultConfigurationName = Release; 359 | }; 360 | 7550647C1BE998B20045DAEB /* Build configuration list for PBXNativeTarget "PrintValueSample" */ = { 361 | isa = XCConfigurationList; 362 | buildConfigurations = ( 363 | 7550647D1BE998B20045DAEB /* Debug */, 364 | 7550647E1BE998B20045DAEB /* Release */, 365 | ); 366 | defaultConfigurationIsVisible = 0; 367 | defaultConfigurationName = Release; 368 | }; 369 | /* End XCConfigurationList section */ 370 | }; 371 | rootObject = 7550645D1BE998B20045DAEB /* Project object */; 372 | } 373 | -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/4. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/4. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample/Model.h: -------------------------------------------------------------------------------- 1 | // 2 | // Model.h 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/4. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface FatherModel : NSObject 13 | { 14 | CGSize size; 15 | } 16 | //@property (nonatomic, assign)CGSize size; 17 | @property (nonatomic, assign)CGVector vector; 18 | @property (nonatomic, assign)CGRect rect; 19 | @property (nonatomic, assign)NSRange nsRange; 20 | @property (nonatomic, assign)CFRange cfRange; 21 | @property (nonatomic, assign)CGAffineTransform transform; 22 | @property (nonatomic, assign)CATransform3D transform3D; 23 | @property (nonatomic, assign)UIOffset offset; 24 | @property (nonatomic, assign)UIEdgeInsets edge; 25 | 26 | 27 | @end 28 | 29 | 30 | 31 | @interface Model : FatherModel 32 | { 33 | NSURL *_URL; 34 | } 35 | @property (nonatomic, strong)NSNumber *number; 36 | @property (nonatomic, strong)NSSet *set; 37 | @property (nonatomic, strong)NSDictionary *dictionary; 38 | 39 | 40 | 41 | 42 | @end 43 | 44 | @interface SonModel : Model 45 | { 46 | NSString * _string; 47 | } 48 | @property (nonatomic, strong)NSDate *date; 49 | @property (nonatomic, assign)CGPoint point; 50 | @property (nonatomic, strong)NSArray *array; 51 | - (void)setIvar; 52 | 53 | @end 54 | 55 | -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample/Model.m: -------------------------------------------------------------------------------- 1 | // 2 | // Model.m 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/4. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import "Model.h" 10 | 11 | @implementation FatherModel 12 | 13 | 14 | @end 15 | 16 | @implementation Model 17 | 18 | @end 19 | 20 | @implementation SonModel 21 | - (void)setIvar 22 | { 23 | size = CGSizeMake(1.34, 6.24); 24 | _string = @"____string"; 25 | _URL = [NSURL URLWithString:@"www.google.com"]; 26 | } 27 | 28 | - (SEL)sele 29 | { 30 | return @selector(setValue:forKey:); 31 | } 32 | @end 33 | 34 | 35 | -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/4. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @property (nonatomic, strong)UIView *selfview; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/4. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "Model.h" 11 | #import "LcPrint.h" 12 | #import "LcPrint+LLDB.h" 13 | 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view, typically from a nib. 23 | 24 | // LcPrintViews(self.view); 25 | 26 | int a= 10; 27 | id value = @(a); 28 | 29 | [self test]; 30 | } 31 | 32 | 33 | - (void)test 34 | { 35 | // LcPrint((int)1); 36 | // LcPrint((short)1); 37 | // LcPrint((long)1); 38 | // LcPrint((unsigned int)1); 39 | // LcPrint((unsigned short)1); 40 | // LcPrint((unsigned long)1); 41 | // LcPrint((float)1.72); 42 | // LcPrint((double)1.432); 43 | // LcPrint(YES); 44 | // LcPrint((char)'c'); 45 | // LcPrint((unsigned char)'a'); 46 | // LcPrint([self class]); 47 | 48 | CGPoint point = CGPointMake(3.8, 4.1); 49 | CGSize size = CGSizeMake(8.3, 9.9); 50 | CGVector vector = CGVectorMake(0.4, 7.4); 51 | NSRange range = NSMakeRange(3, 4); 52 | CFRange cfRange = CFRangeMake(2, 6.6); 53 | CGAffineTransform transform = CGAffineTransformMake(1.3, 2.4, 4.5, 3, 6, 6.3); 54 | CATransform3D transform3D = CATransform3DIdentity; 55 | UIOffset offset = UIOffsetMake(5.2, 2); 56 | UIEdgeInsets insets = UIEdgeInsetsMake(9.3, 3.2, 2.1, 4.5); 57 | CGRect rect = CGRectMake(0, 0.4, 8.3, 8.1); 58 | 59 | // LcPrint(point); 60 | // LcPrint(size); 61 | // LcPrint(vector); 62 | // LcPrint(range); 63 | // LcPrint(cfRange); 64 | // LcPrint(transform); 65 | // LcPrint(transform3D); 66 | // LcPrint(offset); 67 | // LcPrint(insets); 68 | // LcPrint(rect); 69 | LcPrint(self.view); 70 | SonModel *model = [SonModel new]; 71 | model.number = @(3.54); 72 | model.date = [NSDate date]; 73 | model.dictionary = @{@"key":@"valur"}; 74 | model.set = [NSSet setWithObjects:@"set1",@"set2", nil]; 75 | model.point = point; 76 | model.vector = vector; 77 | model.nsRange = range; 78 | model.cfRange = cfRange; 79 | model.transform = transform; 80 | model.transform3D = transform3D; 81 | model.offset = offset; 82 | model.edge = insets; 83 | model.rect = rect; 84 | [model setIvar]; 85 | // id value =[model valueForKey:@"charPoint"]; 86 | Model *father = [Model new]; 87 | model.array = @[father,father]; 88 | oo(model); 89 | LcPrint(model); 90 | // LcPrint(model); 91 | } 92 | 93 | - (void)didReceiveMemoryWarning { 94 | [super didReceiveMemoryWarning]; 95 | // Dispose of any resources that can be recreated. 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /PrintValueSample/PrintValueSample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PrintValueSample 4 | // 5 | // Created by jiangliancheng on 15/11/4. 6 | // Copyright © 2015年 jiangliancheng. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PrintValue 2 | 3 | 1. help you show value of object in lldb 4 | 2. direct print value in code without convert it to NSString by using NSLog(). 5 | 6 | ---- 7 | 8 | ##version 2.0 9 | 1. simplify API, make it use more convenient 10 | 1. `p o()` instead of `p LcPrintObj()` 11 | 2. add some method 12 | 1. `p oo()` in lldb to circle print super class's value 13 | 2. `p v()` in lldb to circle print view's subview 14 | 3. `p i()` in lldb to print object's inner, it show ivar, property, method of object 15 | 4. `p ii()` in lldb to circle print super class of object's inner 16 | 5. `LcPrintViews()` in code to circle print view's subview. 17 | 18 | 19 | ##version 1.1 20 | introduce print any var function from [DeveloperLx/LxDBAnything](https://github.com/DeveloperLx/LxDBAnything)。you can use `LcPrint()` instead of `LcPrintObj()` to print any var in code. but if you want to print object in LLDB, you must use `LcPrintObj()`, because `LcPrint()` is macro, which is not supported in LLDB console. and if you want to print basic var(not a NSObject instance) in LLDB, using `p var` direct print it. 21 | 22 | ##Installation 23 | ###Objective-C: 24 | 25 | 1. Download the PrintValue repository as a zip file or clone it 26 | 2. copy `LcPrint` sub-folder into your Xcode project 27 | 3. import `LcPrint+LLDB.h` to your .pch file to make it auto completion in lldb 28 | 29 | if your project don't have .pch file. don't worry. it's still work without auto-completion 30 | 31 | ###Swift: 32 | 33 | 1. Download the PrintValue repository as a zip file or clone it 34 | 2. copy `LcPrint` sub-folder into your Xcode project 35 | 3. import `LcPrint+LLDB.h` to your bridge-header.h file 36 | 37 | if you want to use method in `LcPrint.h`, also import `LcPrint.h` to your bridge-header.h file 38 | 39 | ##Usage 40 | ###LLDB 41 | 42 | ####use `p o()` print object 43 | this method will print an object's property (and ivar) 44 | 45 | (lldb) p o(model) 46 | (SonModel *){ 47 | _string = (NSString *)____string 48 | date = (NSDate *)2015-11-08 13:02:33 +0000 49 | point = (CFRange)(x = 3.8, y = 4.1) 50 | array = (NSArray *)[ 51 | (Model *){ 52 | _URL = nil 53 | number = nil 54 | set = nil 55 | dictionary = nil 56 | }(Model *) 57 | (Model *){ 58 | _URL = nil 59 | number = nil 60 | set = nil 61 | dictionary = nil 62 | }(Model *) 63 | ] 64 | }(SonModel *) 65 | 66 | ####use `p oo()` print object deeply 67 | this method will circle print object's super class 68 | 69 | (lldb) p oo(model) 70 | (SonModel *){ 71 | (Model *){ 72 | (FatherModel *){ 73 | size = (CFRange)(width = 1.34, height = 6.24) 74 | vector = (CFRange)(dx = 0.4, dy = 7.4) 75 | rect = (CFRange)( 76 | CGPoint = (x = 0, y = 0.4) 77 | CGSize = (width = 8.3, height = 8.1) 78 | ) 79 | nsRange = (CFRange)(location = 3, length = 4) 80 | cfRange = (CFRange)(location = 2, length = 6) 81 | transform = (CFRange)( 82 | a = 1.3, b = 2.4, c = 4.5, d = 3 83 | tx = 6, ty = 6.3 84 | ) 85 | transform3D = (CFRange)( 86 | m11 = 1, m12 = 0, m13 = 0, m14 = 0 87 | m21 = 0, m22 = 1, m23 = 0, m24 = 0 88 | m31 = 0, m32 = 0, m33 = 1, m34 = 0 89 | m41 = 0, m42 = 0, m43 = 1, m44 = 0 90 | ) 91 | offset = (CFRange)(horizontal = 5.2, vertical = 2) 92 | edge = (CFRange)(top = 9.3, left = 3.2, bottom = 2.1, right = 4.5) 93 | }(FatherModel *) 94 | _URL = (NSURL *)www.google.com 95 | number = (double)3.54 96 | set = (NSSet *)[ 97 | (NSString *)set1 98 | (NSString *)set2 99 | ] 100 | dictionary = { 101 | key:(NSString *)valur 102 | } 103 | }(Model *) 104 | _string = (NSString *)____string 105 | date = (NSDate *)2015-11-08 13:07:42 +0000 106 | point = (CFRange)(x = 3.8, y = 4.1) 107 | array = nil 108 | }(SonModel *) 109 | 110 | ####use `p v()` circle print view's subviews 111 | this method will circle print the view's subviews 112 | 113 | (lldb) p v(self.view) 114 | 0 💙 > 115 | 1 💙 > 116 | 1 💙 <_UILayoutGuide: 0x7ff0ca7259f0; frame = (0 0; 0 0); hidden = YES; layer = > 117 | 1 💙 <_UILayoutGuide: 0x7ff0ca726b30; frame = (0 0; 0 0); hidden = YES; layer = > 118 | 119 | ####use `p i()` print object's inner 120 | this method will print object's ivar, property, method 121 | 122 | (lldb) p i(model) 123 | (SonModel *){ 124 | @Ivar{ 125 | _string 126 | _date 127 | _array 128 | _point 129 | } 130 | @Property{ 131 | date 132 | point 133 | array 134 | } 135 | @Method{ 136 | -setIvar 137 | -sele 138 | -setArray: 139 | -.cxx_destruct 140 | -array 141 | -date 142 | -point 143 | -setDate: 144 | -setPoint: 145 | } 146 | }(SonModel *) 147 | 148 | ####use `p ii()` circle print object's inner 149 | this method will circle print super class of object 150 | 151 | (lldb) p ii(model) 152 | (SonModel *){ 153 | (Model *){ 154 | @Ivar{ 155 | _URL 156 | _number 157 | _set 158 | _dictionary 159 | } 160 | @Property{ 161 | number 162 | set 163 | dictionary 164 | } 165 | @Method{ 166 | -setSet: 167 | -setDictionary: 168 | -.cxx_destruct 169 | -set 170 | -dictionary 171 | -number 172 | -setNumber: 173 | } 174 | }(Model *) 175 | @Ivar{ 176 | _string 177 | _date 178 | _array 179 | _point 180 | } 181 | @Property{ 182 | date 183 | point 184 | array 185 | } 186 | @Method{ 187 | -setIvar 188 | -sele 189 | -setArray: 190 | -.cxx_destruct 191 | -array 192 | -date 193 | -point 194 | -setDate: 195 | -setPoint: 196 | } 197 | }(SonModel *) 198 | 199 | 200 | ###Code 201 | ####use `LcPrint()` print any var in code 202 | 203 | print basic type: 204 | 205 | LcPrint((int)1); 206 | LcPrint((short)1); 207 | LcPrint((long)1); 208 | LcPrint((unsigned int)1); 209 | LcPrint((unsigned short)1); 210 | LcPrint((unsigned long)1); 211 | LcPrint((float)1.72); 212 | LcPrint((double)1.432); 213 | LcPrint(YES); 214 | LcPrint((char)'c'); 215 | LcPrint((unsigned char)'a'); 216 | LcPrint([self class]); 217 | 218 | ---------result---------- 219 | 220 | ViewController.m, -[ViewController test], Line:35 221 | ❤️(int)1 = (int)1 222 | ViewController.m, -[ViewController test], Line:36 223 | ❤️(short)1 = (short)1 224 | ViewController.m, -[ViewController test], Line:37 225 | ❤️(long)1 = (long)1 226 | ViewController.m, -[ViewController test], Line:38 227 | ❤️(unsigned int)1 = (unsigned int)1 228 | ViewController.m, -[ViewController test], Line:39 229 | ❤️(unsigned short)1 = (unsigned short)1 230 | ViewController.m, -[ViewController test], Line:40 231 | ❤️(unsigned long)1 = (unsigned long)1 232 | ViewController.m, -[ViewController test], Line:41 233 | ❤️(float)1.72 = (float)-2 234 | ViewController.m, -[ViewController test], Line:42 235 | ❤️(double)1.432 = (double)1.432 236 | ViewController.m, -[ViewController test], Line:43 237 | ❤️__objc_yes = (BOOL)YES 238 | ViewController.m, -[ViewController test], Line:44 239 | ❤️(char)'c' = (char)'c' 240 | ViewController.m, -[ViewController test], Line:45 241 | ❤️(unsigned char)'a' = (unsigned char)'a' 242 | ViewController.m, -[ViewController test], Line:46 243 | ❤️[self class] = (Class)ViewController 244 | 245 | print system struct type: 246 | 247 | CGPoint point = CGPointMake(3.8, 4.1); 248 | CGSize size = CGSizeMake(8.3, 9.9); 249 | CGVector vector = CGVectorMake(0.4, 7.4); 250 | NSRange range = NSMakeRange(3, 4); 251 | CFRange cfRange = CFRangeMake(2, 6.6); 252 | CGAffineTransform transform = CGAffineTransformMake(1.3, 2.4, 4.5, 3, 6, 6.3); 253 | CATransform3D transform3D = CATransform3DIdentity; 254 | UIOffset offset = UIOffsetMake(5.2, 2); 255 | UIEdgeInsets insets = UIEdgeInsetsMake(9.3, 3.2, 2.1, 4.5); 256 | CGRect rect = CGRectMake(0, 0.4, 8.3, 8.1); 257 | 258 | LcPrint(point); 259 | LcPrint(size); 260 | LcPrint(vector); 261 | LcPrint(range); 262 | LcPrint(cfRange); 263 | LcPrint(transform); 264 | LcPrint(transform3D); 265 | LcPrint(offset); 266 | LcPrint(insets); 267 | LcPrint(rect); 268 | 269 | ---------result---------- 270 | 271 | ViewController.m, -[ViewController test], Line:59 272 | ❤️point = (CGPoint)(x = 3.8, y = 4.1) 273 | ViewController.m, -[ViewController test], Line:60 274 | ❤️size = (CGSize)(width = 8.3, height = 9.9) 275 | ViewController.m, -[ViewController test], Line:61 276 | ❤️vector = (CGVector)(dx = 0.4, dy = 7.4) 277 | ViewController.m, -[ViewController test], Line:62 278 | ❤️range = (NSRange)(location = 3, length = 4) 279 | ViewController.m, -[ViewController test], Line:63 280 | ❤️cfRange = (CFRange)(location = 2, length = 6) 281 | ViewController.m, -[ViewController test], Line:64 282 | ❤️transform = (CGAffineTransform)( 283 | a = 1.3, b = 2.4, c = 4.5, d = 3 284 | tx = 6, ty = 6.3 285 | ) 286 | ViewController.m, -[ViewController test], Line:65 287 | ❤️transform3D = (CATransform3D)( 288 | m11 = 1, m12 = 0, m13 = 0, m14 = 0 289 | m21 = 0, m22 = 1, m23 = 0, m24 = 0 290 | m31 = 0, m32 = 0, m33 = 1, m34 = 0 291 | m41 = 0, m42 = 0, m43 = 1, m44 = 0 292 | ) 293 | ViewController.m, -[ViewController test], Line:66 294 | ❤️offset = (UIOffset)(horizontal = 5.2, vertical = 2) 295 | ViewController.m, -[ViewController test], Line:67 296 | ❤️insets = (UIEdgeInsets)(top = 9.3, left = 3.2, bottom = 2.1, right = 4.5) 297 | ViewController.m, -[ViewController test], Line:68 298 | ❤️rect = (CGRect)( 299 | CGPoint = (x = 0, y = 0.4) 300 | CGSize = (width = 8.3, height = 8.1) 301 | ) 302 | 303 | print object : 304 | 305 | Model *model = [Model new]; 306 | model.string = @"modelString"; 307 | model.number = @(3.54); 308 | model.URL = [NSURL URLWithString:@"http://www.baidu.com"]; 309 | model.date = [NSDate date]; 310 | model.array = @[@"a",@"b",@"c"]; 311 | model.dictionary = @{@"key":@"valur"}; 312 | model.set = [NSSet setWithObjects:@"set1",@"set2", nil]; 313 | model.point = point; 314 | model.size = size; 315 | model.vector = vector; 316 | model.nsRange = range; 317 | model.cfRange = cfRange; 318 | model.transform = transform; 319 | model.transform3D = transform3D; 320 | model.offset = offset; 321 | model.edge = insets; 322 | model.rect = rect; 323 | 324 | LcPrint(model); 325 | ---------result---------- 326 | 327 | ViewController.m, -[ViewController test], Line:89 328 | ❤️model = (Model *){ 329 | size = (CFRange)(width = 8.3, height = 9.9) 330 | vector = (CFRange)(dx = 0.4, dy = 7.4) 331 | rect = (CFRange)( 332 | CGPoint = (x = 0, y = 0.4) 333 | CGSize = (width = 8.3, height = 8.1) 334 | ) 335 | nsRange = (CFRange)(location = 3, length = 4) 336 | cfRange = (CFRange)(location = 2, length = 6) 337 | transform = (CFRange)( 338 | a = 1.3, b = 2.4, c = 4.5, d = 3 339 | tx = 6, ty = 6.3 340 | ) 341 | transform3D = (CFRange)( 342 | m11 = 1, m12 = 0, m13 = 0, m14 = 0 343 | m21 = 0, m22 = 1, m23 = 0, m24 = 0 344 | m31 = 0, m32 = 0, m33 = 1, m34 = 0 345 | m41 = 0, m42 = 0, m43 = 1, m44 = 0 346 | ) 347 | offset = (CFRange)(horizontal = 5.2, vertical = 2) 348 | edge = (CFRange)(top = 9.3, left = 3.2, bottom = 2.1, right = 4.5) 349 | point = (CFRange)(x = 3.8, y = 4.1) 350 | array = (NSArray *)[ 351 | (NSString *)a 352 | (NSString *)b 353 | (NSString *)c 354 | ] 355 | string = (NSString *)modelString 356 | URL = (NSURL *)http://www.baidu.com 357 | date = (NSDate *)2015-11-08 13:53:26 +0000 358 | number = (double)3.54 359 | set = (NSSet *)[ 360 | (NSString *)set1 361 | (NSString *)set2 362 | ] 363 | dictionary = { 364 | key:(NSString *)valur 365 | } 366 | }(Model *) 367 | ####use `p LcPrintViews()` circle print view's subviews 368 | it the same of `p v()` in lldb. 369 | 370 | --------------------------------------------------------------------------------