2014 snapchat source code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
920 B

  1. #import "UIScreen+Debug.h"
  2. #import <SCFoundation/SCAppEnvironment.h>
  3. #import <SCFoundation/SCLog.h>
  4. #import <objc/runtime.h>
  5. @implementation UIScreen (Debug)
  6. + (void)load
  7. {
  8. if (SCIsPerformanceLoggingEnabled()) {
  9. static dispatch_once_t once_token;
  10. dispatch_once(&once_token, ^{
  11. SEL setBrightnessSelector = @selector(setBrightness:);
  12. SEL setBrightnessLoggerSelector = @selector(logged_setBrightness:);
  13. Method originalMethod = class_getInstanceMethod(self, setBrightnessSelector);
  14. Method extendedMethod = class_getInstanceMethod(self, setBrightnessLoggerSelector);
  15. method_exchangeImplementations(originalMethod, extendedMethod);
  16. });
  17. }
  18. }
  19. - (void)logged_setBrightness:(CGFloat)brightness
  20. {
  21. SCLogGeneralInfo(@"Setting brightness from %f to %f", self.brightness, brightness);
  22. [self logged_setBrightness:brightness];
  23. }
  24. @end