77 lines
2.3 KiB
Objective-C
77 lines
2.3 KiB
Objective-C
//
|
|
// XSHelper.h
|
|
// nochange
|
|
//
|
|
// Created by mac on 2024/10/15.
|
|
//
|
|
|
|
#ifndef XSHelper_h
|
|
#define XSHelper_h
|
|
|
|
#import <UIKit/UIKit.h>
|
|
#import <Vision/Vision.h>
|
|
#import <CommonCrypto/CommonDigest.h>
|
|
#import <CommonCrypto/CommonCryptor.h>
|
|
|
|
|
|
// 在头文件定义宏
|
|
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
|
|
#define RGB(r,g,b) RGBA(r,g,b,1.0f)
|
|
|
|
|
|
typedef void (^MyOCRCallback)(NSString *text);
|
|
typedef void (^NextCallback)(void);
|
|
|
|
float XSRoundToDecimal(float value, int decimalPlaces);
|
|
double XSCalculateElapsedTime(uint64_t start, uint64_t end) ;
|
|
void XSAfterNext(int sec, NextCallback next);
|
|
|
|
NSError* XSErrorFromException(NSException* exception);
|
|
|
|
@interface XSHelper : NSObject
|
|
{
|
|
|
|
}
|
|
|
|
+ (NSString *)readFileText: (NSString *)path;
|
|
+ (BOOL) saveFile: (NSString *) path data: (NSData *)data;
|
|
+ (BOOL) saveFile: (NSString *) path text: (NSString *)text;
|
|
+ (void) rmFiles: (NSString *) path;
|
|
+ (UIImage *) imageFromFile:(NSString *) path;
|
|
+ (NSString *)data2str: (NSData *) data;
|
|
+ (NSData *)str2Data:(NSString *)str;
|
|
+ (BOOL) strIsEmpty: (NSString *)str;
|
|
+ (NSDictionary *) json2Dictionary: (NSString *)json;
|
|
+ (NSDictionary *) jsonData2Dictionary: (NSData *)data;
|
|
+ (NSString *)dic2Json: (NSDictionary *)dict;
|
|
+ (NSData *)obj2JsonData:(id)obj;
|
|
+ (NSNumber *)str2num:(NSString *)str;
|
|
+ (bool) isMatch: (NSString *)pattern test:(NSString *)test;
|
|
+ (NSString *)replaceStr: (NSString *)text oldStr:(NSString *)oldStr newStr: (NSString *)newStr;
|
|
+ (void)replaceMulStr: (NSMutableString *)text oldStr:(NSString *)oldStr newStr: (NSString *)newStr;
|
|
+ (NSString *)replaceStr: (NSString *)text regex:(NSString *)regex newStr:(NSString *)newStr;
|
|
+ (UIImage *)png2jpg:(UIImage *)png;
|
|
+ (void)performOCROnImage:(UIImage *)image callback:(MyOCRCallback) callback;
|
|
+ (NSString *)base64StringFromJpgImage:(UIImage *)image;
|
|
+ (UIImage *)imageFromBase64String:(NSString *)base64String;
|
|
+ (double) getCurTime;
|
|
+ (int)random:(int)min and:(int)max;
|
|
@end
|
|
|
|
|
|
@interface NSData (AES)
|
|
|
|
- (NSData *)aesEncrypt: (NSString *)key iv:(NSString *)iv;
|
|
- (NSData *)aesDecrypt: (NSString *)key iv:(NSString *)iv;
|
|
|
|
@end
|
|
|
|
@interface NSString (AES)
|
|
- (NSString *)aesEncrypt: (NSString *)key iv:(NSString *)iv;
|
|
- (NSString *)aesDecrypt: (NSString *)key iv:(NSString *)iv;
|
|
@end
|
|
|
|
|
|
|
|
#endif /* XSHelper_h */
|