Last active
September 3, 2019 09:02
-
-
Save mralexgray/b51a60dac974b9f952a0 to your computer and use it in GitHub Desktop.
A concise category on NSObject to log all declared properties, pretty-like, using minimal SLOC.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <objc/message.h> | |
#define DECORATE printf("\n\n+*%%$%%*+-+*%%$%%*+-+*%%$-+*%%$%%*+-+*%%$%%*+-+*%%$-+*%%$%%*+-+*%%$%%*+-\n\n") | |
@implementation NSObject (logProperties) - (void) logProperties { DECORATE; @autoreleasepool { unsigned int propCt = 0; | |
const char * myName = [self.description substringWithRange: | |
(NSRange){1,[self.description rangeOfString:@":"].location-1}].UTF8String; | |
objc_property_t *pA = class_copyPropertyList(self.class, &propCt); | |
for (int i = 0; i < propCt; i++) { NSString *name; printf("%s [%s] = %s\n", myName, | |
(name = [NSString.alloc initWithUTF8String:property_getName(pA[i])]).UTF8String, | |
[objc_msgSend(self,NSSelectorFromString(name)) description].UTF8String); | |
} free(pA); } DECORATE; } | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+*%$%*+-+*%$%*+-+*%$-+*%$%*+-+*%$%*+-+*%$-+*%$%*+-+*%$%*+- | |
BLWebSocketsServer [running] = (null) | |
BLWebSocketsServer [port] = (null) | |
BLWebSocketsServer [protocolName] = (null) | |
BLWebSocketsServer [completionBlock] = (null) | |
BLWebSocketsServer [timer] = (null) | |
BLWebSocketsServer [networkQueue] = <OS_dispatch_queue: com.blwebsocketsserver.network[0x10010aa80]> | |
BLWebSocketsServer [context] = (null) | |
BLWebSocketsServer [asyncMessageQueue] = <BLAsyncMessageQueue: 0x100102370> | |
BLWebSocketsServer [handleRequestBlock] = <__NSGlobalBlock__: 0x100007300> | |
BLWebSocketsServer [sessionIdIncrementalCount] = (null) | |
+*%$%*+-+*%$%*+-+*%$-+*%$%*+-+*%$%*+-+*%$-+*%$%*+-+*%$%*+- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment