FLEXUtility.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #define FLEXFloor(x) (floor([[UIScreen mainScreen] scale] * (x)) / [[UIScreen mainScreen] scale])
  11. @interface FLEXUtility : NSObject
  12. + (UIColor *)consistentRandomColorForObject:(id)object;
  13. + (NSString *)descriptionForView:(UIView *)view includingFrame:(BOOL)includeFrame;
  14. + (NSString *)stringForCGRect:(CGRect)rect;
  15. + (UIViewController *)viewControllerForView:(UIView *)view;
  16. + (NSString *)detailDescriptionForView:(UIView *)view;
  17. + (UIImage *)circularImageWithColor:(UIColor *)color radius:(CGFloat)radius;
  18. + (UIColor *)scrollViewGrayColor;
  19. + (UIColor *)hierarchyIndentPatternColor;
  20. + (NSString *)applicationImageName;
  21. + (NSString *)applicationName;
  22. + (NSString *)safeDescriptionForObject:(id)object;
  23. + (UIFont *)defaultFontOfSize:(CGFloat)size;
  24. + (UIFont *)defaultTableViewCellLabelFont;
  25. + (NSString *)stringByEscapingHTMLEntitiesInString:(NSString *)originalString;
  26. + (UIInterfaceOrientationMask)infoPlistSupportedInterfaceOrientationsMask;
  27. + (NSString *)searchBarPlaceholderText;
  28. + (BOOL)isImagePathExtension:(NSString *)extension;
  29. + (UIImage *)thumbnailedImageWithMaxPixelDimension:(NSInteger)dimension fromImageData:(NSData *)data;
  30. + (NSString *)stringFromRequestDuration:(NSTimeInterval)duration;
  31. + (NSString *)statusCodeStringFromURLResponse:(NSURLResponse *)response;
  32. + (NSDictionary *)dictionaryFromQuery:(NSString *)query;
  33. + (NSString *)prettyJSONStringFromData:(NSData *)data;
  34. + (BOOL)isValidJSONData:(NSData *)data;
  35. + (NSData *)inflatedDataFromCompressedData:(NSData *)compressedData;
  36. // Swizzling utilities
  37. + (SEL)swizzledSelectorForSelector:(SEL)selector;
  38. + (BOOL)instanceRespondsButDoesNotImplementSelector:(SEL)selector class:(Class)cls;
  39. + (void)replaceImplementationOfKnownSelector:(SEL)originalSelector onClass:(Class)class withBlock:(id)block swizzledSelector:(SEL)swizzledSelector;
  40. + (void)replaceImplementationOfSelector:(SEL)selector withSelector:(SEL)swizzledSelector forClass:(Class)cls withMethodDescription:(struct objc_method_description)methodDescription implementationBlock:(id)implementationBlock undefinedBlock:(id)undefinedBlock;
  41. @end