FLEXUtility.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // FLEXUtility.h
  3. // Flipboard
  4. //
  5. // Created by Ryan Olson on 4/18/14.
  6. // Copyright (c) 2014 Flipboard. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. #import <objc/runtime.h>
  11. #define FLEXFloor(x) (floor([[UIScreen mainScreen] scale] * (x)) / [[UIScreen mainScreen] scale])
  12. @interface FLEXUtility : NSObject
  13. + (UIColor *)consistentRandomColorForObject:(id)object;
  14. + (NSString *)descriptionForView:(UIView *)view includingFrame:(BOOL)includeFrame;
  15. + (NSString *)stringForCGRect:(CGRect)rect;
  16. + (UIViewController *)viewControllerForView:(UIView *)view;
  17. + (UIViewController *)viewControllerForAncestralView:(UIView *)view;
  18. + (NSString *)detailDescriptionForView:(UIView *)view;
  19. + (UIImage *)circularImageWithColor:(UIColor *)color radius:(CGFloat)radius;
  20. + (UIColor *)scrollViewGrayColor;
  21. + (UIColor *)hierarchyIndentPatternColor;
  22. + (NSString *)applicationImageName;
  23. + (NSString *)applicationName;
  24. + (NSString *)safeDescriptionForObject:(id)object;
  25. + (UIFont *)defaultFontOfSize:(CGFloat)size;
  26. + (UIFont *)defaultTableViewCellLabelFont;
  27. + (NSString *)stringByEscapingHTMLEntitiesInString:(NSString *)originalString;
  28. + (UIInterfaceOrientationMask)infoPlistSupportedInterfaceOrientationsMask;
  29. + (NSString *)searchBarPlaceholderText;
  30. + (BOOL)isImagePathExtension:(NSString *)extension;
  31. + (UIImage *)thumbnailedImageWithMaxPixelDimension:(NSInteger)dimension fromImageData:(NSData *)data;
  32. + (NSString *)stringFromRequestDuration:(NSTimeInterval)duration;
  33. + (NSString *)statusCodeStringFromURLResponse:(NSURLResponse *)response;
  34. + (NSDictionary *)dictionaryFromQuery:(NSString *)query;
  35. + (NSString *)prettyJSONStringFromData:(NSData *)data;
  36. + (BOOL)isValidJSONData:(NSData *)data;
  37. + (NSData *)inflatedDataFromCompressedData:(NSData *)compressedData;
  38. + (NSArray *)allWindows;
  39. // Swizzling utilities
  40. + (SEL)swizzledSelectorForSelector:(SEL)selector;
  41. + (BOOL)instanceRespondsButDoesNotImplementSelector:(SEL)selector class:(Class)cls;
  42. + (void)replaceImplementationOfKnownSelector:(SEL)originalSelector onClass:(Class)class withBlock:(id)block swizzledSelector:(SEL)swizzledSelector;
  43. + (void)replaceImplementationOfSelector:(SEL)selector withSelector:(SEL)swizzledSelector forClass:(Class)cls withMethodDescription:(struct objc_method_description)methodDescription implementationBlock:(id)implementationBlock undefinedBlock:(id)undefinedBlock;
  44. @end