Skip to content

Instantly share code, notes, and snippets.

@OliverLetterer
Created July 21, 2013 18:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OliverLetterer/6049349 to your computer and use it in GitHub Desktop.
Save OliverLetterer/6049349 to your computer and use it in GitHub Desktop.
Log all used CAFilter operations
typedef struct CAColorMatrix {
float m11, m12, m13, m14, m15;
float m21, m22, m23, m24, m25;
float m31, m32, m33, m34, m35;
float m41, m42, m43, m44, m45;
} CAColorMatrix;
@interface CAFilter : NSObject
@property(copy) NSString *name;
@property(readonly) NSString *type;
@end
@implementation NSValue (CAFilterVerbose)
+ (void)load
{
class_swizzleSelector(self, @selector(description), @selector(__verboseDescription));
}
- (NSString *)__verboseDescription
{
if (strcmp(self.objCType, @encode(CAColorMatrix)) == 0) {
CAColorMatrix colorMatrix;
[self getValue:&colorMatrix];
return [NSString stringWithFormat:@"CAColorMatrix: {{%lf, %lf, %lf, %lf, %lf}, {%lf, %lf, %lf, %lf, %lf}, {%lf, %lf, %lf, %lf, %lf}, {%lf, %lf, %lf, %lf, %lf}}", colorMatrix.m11, colorMatrix.m12, colorMatrix.m13, colorMatrix.m14, colorMatrix.m15, colorMatrix.m21, colorMatrix.m22, colorMatrix.m23, colorMatrix.m24, colorMatrix.m25, colorMatrix.m31, colorMatrix.m32, colorMatrix.m33, colorMatrix.m34, colorMatrix.m35, colorMatrix.m41, colorMatrix.m42, colorMatrix.m43, colorMatrix.m44, colorMatrix.m45];
}
return [self __verboseDescription];
}
@end
@implementation CAFilter (Verbose)
+ (void)load
{
class_swizzleSelector(self, @selector(setValue:forKey:), @selector(__verboseSetValue:forKey:));
}
- (void)__verboseSetValue:(id)value forKey:(NSString *)key
{
[self __verboseSetValue:value forKey:key];
NSLog(@"%@[%@] = %@", self.name, key, value);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment