RAUtils.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // RAUtils.h
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 9/17/15.
  6. // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. //typedef struct {
  11. //
  12. // NSString* id;
  13. //
  14. // float height;
  15. //
  16. //
  17. //}MyTestStruct;
  18. #define DEBUGLOG 1
  19. #ifdef DEBUGLOG
  20. #ifdef DEBUG
  21. // #define DebugLog( s, ... ) fprintf(stderr,"%s\n",[[NSString stringWithFormat:s, ##__VA_ARGS__] UTF8String])//
  22. #define DebugLog( s, ... ) fprintf(stderr, "<%p %s:(%d)> %s \n", self, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent]UTF8String], __LINE__, [[NSString stringWithFormat:(s), ##__VA_ARGS__]UTF8String] )
  23. #define blockDebugLog( s, ... ) fprintf(stderr, "<%p %s:(%d)> %s \n",weakself, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent]UTF8String], __LINE__, [[NSString stringWithFormat:(s), ##__VA_ARGS__]UTF8String] )
  24. #else
  25. #define DebugLog( s, ... )
  26. #define blockDebugLog( s, ... )
  27. #endif
  28. #else
  29. #define DebugLog( s, ... )
  30. #define blockDebugLog( s, ... )
  31. #endif
  32. NS_ASSUME_NONNULL_BEGIN
  33. @interface RAUtils : NSObject
  34. + (CGSize)sizeWithFont:(NSString*_Nonnull)string font:(UIFont *_Nonnull)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode;
  35. + (BOOL)isNumeric:(NSString*)string;
  36. //+(NSData*) dict2data:(NSDictionary*) dict;
  37. +(NSString*) FloatFormat:(float)value;
  38. +(UIViewController*) getViewController:(UIView*) view;
  39. + (CGRect)relativeFrameForScreenWithView:(UIView *)v;
  40. +(NSDictionary*) error_json :(int)code err_msg:(NSString* _Nullable)msg;
  41. +(UIAlertController*) message_alert :(NSString* _Nullable) msg title:(NSString*_Nullable) title controller:(UIViewController*) vc;
  42. +(UIAlertController*) message_alert :(NSString*) msg title:(NSString*) title controller:(UIViewController*) vc action_handler:(void (^ __nullable)(UIAlertAction *action))action_handler completion:(void (^ __nullable)(void))completion;
  43. //+(void) alert_view :(NSString*) msg title:(NSString*) title ;
  44. //+(UIAlertView * ) waiting_alert :(NSString*) msg title:(NSString*) title;
  45. //+(UIAlertController*) waiting_alert:(UIViewController*)parent title:(NSString*_Nullable) title;
  46. +(UIAlertController*) waiting_alert:(UIViewController*)parent title:(NSString*) title completion:(void (^ __nullable)(void))completion;
  47. //+(UIAlertController*) waiting_alert:(UIViewController*)parent message:(NSString*_Nullable)msg title:(NSString*_Nullable) title;
  48. +(UIAlertController*) waiting_alert:(UIViewController*)parent message:(NSString*)msg title:(NSString*) title completion:(void (^ __nullable)(void))completion;
  49. + (float)fileSizeForDir:(NSString*)path;//计算文件夹下文件的总大小;
  50. +(void) deletefiles :(NSString*) path;
  51. +(UIColor*) strColor:(NSString*) color;
  52. +(NSString*) get_config_path;
  53. +(NSString*) base64en:(NSString*) string;
  54. +(NSString*) base64de:(NSString*) string;
  55. +(NSDictionary*) device_info;
  56. +(NSDictionary*) error_dict:(NSError*)error;
  57. + (NSArray*) allFilesAtPath:(NSString*) dirString;
  58. //+(void) enum_font;
  59. +(NSDictionary*) dictfromfile:(NSString*) path;
  60. //+(NSArray*) expression_varable:(NSString*)content regex:(NSString*) pattern;
  61. //+(NSTextCheckingResult*) expression_findfistMatch:(NSString*)content regex:(NSString*) pattern;
  62. +(NSData*) getdbfile:(NSString*)dbname;
  63. // 2020-1118 去掉zip 如果以后需要用到,单独加在其他包内
  64. //+(NSString*) getdbzip:(NSString*)dbname;
  65. + (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size;
  66. + (CGRect)scaleToSize:(CGRect )from to:(CGSize)to;
  67. + (CGRect)rectAlign:(CGRect )parent rect:(CGRect)rect hAlign:(NSString*)hAlign vAlign:(NSString*)vAlign;
  68. + (CGRect)rectVAlign:(CGRect )parent rect:(CGRect)rect vAlign:(NSString*)vAlign;
  69. +(UIImage*)img_compress:(UIImage*)image kbsize:(float) size;
  70. +(NSString* )current_date;
  71. +(NSString*) current_date_time;
  72. +(NSString*) current_date_forfile;
  73. +(NSMutableArray*)dictionary2array:(NSDictionary*)json count_fields:(NSString*) count_fields item_mark:(NSString*) item_mark items_mark:(NSString* _Nullable )items_mark;
  74. +(int)getRandomNumber:(int)from to:(int)to;
  75. //+(void) add_recent_model:(NSDictionary*) model;
  76. + (long long) freeDiskSpaceInMegaBytes;
  77. //+(NSArray*) string2arr:(NSString*) string separator:(NSString*)separator;
  78. + (bool)mergeContentsOfPath:(NSString *)srcDir intoPath:(NSString *)dstDir error:(NSError**)err;
  79. + (BOOL)saveData:(NSData *)data toPath:(NSString *)path;
  80. + (void)removeFileAtPath:(NSString *)path;
  81. + (NSString *)appCacheDirectory;
  82. +(NSString*)md5WithFile:(NSString*)path;
  83. + (BOOL)fileExistsAtPath:(NSString *)path;
  84. + (NSString *)htmlForVideo:(NSString*) iframeCode template:(NSString*) path;
  85. + (NSString *)htmlForImage:(UIImage *)image template:(NSString*) path;
  86. + (CGRect)relativeFrame:(CGRect) frame FromView:(UIView *)v toView:(UIView*)tv;
  87. + (nullable NSString *)md5:(nullable NSString *)str;
  88. + (NSString *_Nullable)deviceID;
  89. + (void)ra_showAlertTitle:(NSString *_Nullable)title message:(NSString *_Nullable)msg withViewController:(UIViewController *_Nonnull)vc;
  90. + (BOOL) validateEmail:(NSString *)email;
  91. + (BOOL)checkPassword:(NSString *) password;
  92. + (UIViewController *)getCurrentVCFrom:(UIViewController *)rootVC;
  93. + (UIViewController *)getCurrentVC;
  94. @end
  95. NS_ASSUME_NONNULL_END