Skip to content

Instantly share code, notes, and snippets.

@evadne
Created January 26, 2011 12:07
Show Gist options
  • Save evadne/796608 to your computer and use it in GitHub Desktop.
Save evadne/796608 to your computer and use it in GitHub Desktop.
Dumping a CG struct.
#include <CoreGraphics/CGBase.h>
#define irDump(aCGStruct) NSLog(@"%@", irDumpImpl(@encode(__typeof__(aCGStruct)), &aCGStruct))
#define irDumpLog(aCGStruct,...) NSLog(@"%@: %@", irDumpImpl(@encode(__typeof__(aCGStruct)), &aCGStruct), [NSString stringWithFormat:__VA_ARGS__])
CG_INLINE NSString* irDumpImpl (const char *encodedString, void * aPointer) {
if (strcmp(encodedString, @encode(CGRect)) == 0)
return NSStringFromCGRect(*(CGRect*)aPointer);
if (strcmp(encodedString, @encode(CGPoint)) == 0)
return NSStringFromCGPoint(*(CGPoint*)aPointer);
if (strcmp(encodedString, @encode(CGSize)) == 0)
return NSStringFromCGSize(*(CGSize*)aPointer);
return @"(Unknown)";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment