| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- //
- // RAUtils.h
- // RedAnt ERP Mobile
- //
- // Created by Ray on 9/17/15.
- // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
- //
- #import <Foundation/Foundation.h>
- #import <UIKit/UIKit.h>
- #import "MessageBox.h"
- //typedef struct {
- //
- // NSString* id;
- //
- // float height;
- //
- //
- //}MyTestStruct;
- #define DEBUGLOG
- #ifdef DEBUGLOG
- #ifdef DEBUG
- // #define DebugLog( s, ... ) fprintf(stderr,"%s\n",[[NSString stringWithFormat:s, ##__VA_ARGS__] UTF8String])//
- #define DebugLog( s, ... ) fprintf(stderr, "<%p %s:(%d)> %s \n", self, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent]UTF8String], __LINE__, [[NSString stringWithFormat:(s), ##__VA_ARGS__]UTF8String] )
- #define blockDebugLog( s, ... ) fprintf(stderr, "<%p %s:(%d)> %s \n",weakself, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent]UTF8String], __LINE__, [[NSString stringWithFormat:(s), ##__VA_ARGS__]UTF8String] )
- #else
- #define DebugLog( s, ... )
- #define blockDebugLog( s, ... )
- #endif
- #else
- #define DebugLog( s, ... )
- #define blockDebugLog( s, ... )
- #endif
- NS_ASSUME_NONNULL_BEGIN
- @interface RAUtils : NSObject
- + (CGSize)sizeWithFont:(NSString*_Nonnull)string font:(UIFont *_Nonnull)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode;
- + (BOOL)isNumeric:(NSString*)string;
- //+(NSData*) dict2data:(NSDictionary*) dict;
- +(NSString*) FloatFormat:(float)value;
- +(UIViewController*) getViewController:(UIView*) view;
- + (CGRect)relativeFrameForScreenWithView:(UIView *)v;
- +(NSDictionary*) error_json :(int)code err_msg:(NSString* _Nullable)msg;
- //+(UIAlertController*) message_alert :(NSString* _Nullable) msg title:(NSString*_Nullable) title controller:(UIViewController*) vc;
- //+(UIAlertController*) message_alert :(NSString*) msg title:(NSString*) title controller:(UIViewController*) vc action_handler:(void (^ __nullable)(UIAlertAction *action))action_handler completion:(void (^ __nullable)(void))completion;
- //+(UIAlertController*) waiting_alert:(UIViewController*)parent title:(NSString*) title completion:(void (^ __nullable)(void))completion;
- //+(UIAlertController*) waiting_alert:(UIViewController*)parent message:(NSString*)msg title:(NSString*) title completion:(void (^ __nullable)(void))completion;
- + (float)fileSizeForDir:(NSString*)path;//计算文件夹下文件的总大小;
- +(void) deletefiles :(NSString*) path;
- +(UIColor*) strColor:(NSString*) color;
- +(NSString*) get_config_path;
- +(NSString*) base64en:(NSString*) string;
- +(NSString*) base64de:(NSString*) string;
- +(NSDictionary*) device_info;
- +(NSDictionary*) error_dict:(NSError*)error;
- + (NSArray*) allFilesAtPath:(NSString*) dirString;
- //+(void) enum_font;
- +(NSDictionary*) dictfromfile:(NSString*) path;
- +(void) dicttofile:(NSString*) path dict:(NSDictionary*)dict;
- //+(NSArray*) expression_varable:(NSString*)content regex:(NSString*) pattern;
- //+(NSTextCheckingResult*) expression_findfistMatch:(NSString*)content regex:(NSString*) pattern;
- +(NSData*) getdbfile:(NSString*)dbname;
- // 2020-1118 去掉zip 如果以后需要用到,单独加在其他包内
- //+(NSString*) getdbzip:(NSString*)dbname;
- + (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size;
- + (CGRect)scaleToSize:(CGRect )from to:(CGSize)to;
- + (CGRect)rectAlign:(CGRect )parent rect:(CGRect)rect hAlign:(NSString*)hAlign vAlign:(NSString*)vAlign;
- + (CGRect)rectVAlign:(CGRect )parent rect:(CGRect)rect vAlign:(NSString*)vAlign;
- +(UIImage*)img_compress:(UIImage*)image kbsize:(float) size;
- +(NSString* )current_date;
- +(NSString*) current_date_time;
- +(NSString*) current_date_forfile;
- +(NSMutableArray*)dictionary2array:(NSDictionary*)json count_fields:(NSString*) count_fields item_mark:(NSString*) item_mark items_mark:(NSString* _Nullable )items_mark;
- +(int)getRandomNumber:(int)from to:(int)to;
- //+(void) add_recent_model:(NSDictionary*) model;
- + (long long) freeDiskSpaceInMegaBytes;
- //+(NSArray*) string2arr:(NSString*) string separator:(NSString*)separator;
- + (UIWindow *)keyWindow;
- + (bool)mergeContentsOfPath:(NSString *)srcDir intoPath:(NSString *)dstDir error:(NSError**)err;
- + (BOOL)saveData:(NSData *)data toPath:(NSString *)path;
- + (void)removeFileAtPath:(NSString *)path;
- + (NSString *)appCacheDirectory;
- +(NSString*)md5WithFile:(NSString*)path;
- + (BOOL)fileExistsAtPath:(NSString *)path;
- + (NSString *)htmlForVideo:(NSString*) iframeCode template:(NSString*) path;
- + (NSString *)htmlForImage:(UIImage *)image template:(NSString*) path;
- + (CGRect)relativeFrame:(CGRect) frame FromView:(UIView *)v toView:(UIView*)tv;
- + (nullable NSString *)md5:(nullable NSString *)str;
- + (NSString *_Nullable)deviceID;
- + (void)ra_showAlertTitle:(NSString *_Nullable)title message:(NSString *_Nullable)msg withViewController:(UIViewController *_Nonnull)vc;
- + (BOOL) validateEmail:(NSString *)email;
- + (BOOL)checkPassword:(NSString *) password;
- + (UIViewController *)getCurrentVCFrom:(UIViewController *)rootVC;
- + (UIViewController *)getCurrentVC;
- +(NSDictionary* )copyDict:(NSDictionary* ) source;
- +(void) playSound:(NSString*) name type:(NSString*) type;
- +(UIInterfaceOrientation)query_orientation:(UIViewController*)vc;
- +(PopWaitAlert*) waiting_pop:(nullable NSString*) title completion:(void (^ __nullable)(void))completion;
- +(MessageBox*) message_box:(nullable NSString*) title message:(nullable NSString*)message completion:(void (^ __nullable)(void))completion;
- @end
- NS_ASSUME_NONNULL_END
|