123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- #import <Foundation/Foundation.h>
- #import <AVFoundation/AVFoundation.h>
- #include <sys/param.h>
- #include <sys/mount.h>
- #define SCREEN_WIDTH [[UIScreen mainScreen]bounds].size.width
- #define SCREEN_HEIGHT [[UIScreen mainScreen]bounds].size.height
- #define DOCUMENT_PATH [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]
- #define ASSET_PATH [DOCUMENT_PATH stringByAppendingPathComponent:@"BioAuth"]
- #define NONE_NIL_STRING(str) (str ? str : @"")
- #define SafeRelease(obj) if(obj){obj=nil;}
- #define SYNC_MAINTHREAD_BEGIN [APBUtils APBMainThread:^{
- #define SYNC_MAINTHREAD_END }];
- static NSString *const kAPBPipeInfoMutexToken = @"";
- static id __apb_thread_safe_object_for_key(NSMutableDictionary *pipeInfo, NSString *key){
- id ret;
- @synchronized(kAPBPipeInfoMutexToken){
- if ([pipeInfo isKindOfClass:[NSMutableDictionary class]] && [pipeInfo objectForKey: key]) {
- ret = [pipeInfo objectForKey:key];
- }
- }
- return ret;
- }
- #define THREAD_SAFE_OBJECT_FOR_KEY(pipeInfo, key) __apb_thread_safe_object_for_key(pipeInfo, key)
- #define THREAD_SAFE_SET_OBJECT_FOR_KEY(pipeInfo, key, value) \
- @synchronized(kAPBPipeInfoMutexToken){ \
- if ([pipeInfo isKindOfClass:[NSMutableDictionary class]] && key && value) { \
- [pipeInfo setObject:value forKey:key];}}
- #define THREAD_SAFE_REMOVE_OBJECT_FOR_KEY(pipeInfo, key) \
- @synchronized(kAPBPipeInfoMutexToken){ \
- if ([pipeInfo isKindOfClass:[NSMutableDictionary class]] && [pipeInfo objectForKey: key]) { \
- [pipeInfo removeObjectForKey: key];}}
- #define INCREASE_BY_ONE(pipeInfo, key){ \
- NSInteger num = [[pipeInfo objectForKey:key]integerValue]+1; \
- THREAD_SAFE_SET_OBJECT_FOR_KEY(pipeInfo, key, [NSNumber numberWithInteger:num]);}
- #define DECREASE_BY_ONE(pipeInfo, key){ \
- NSInteger num = [[pipeInfo objectForKey:key]integerValue]-1; \
- THREAD_SAFE_SET_OBJECT_FOR_KEY(pipeInfo, key, [NSNumber numberWithInteger:--num]);}
- #define LOCK(locker, ...) dispatch_semaphore_wait(locker, DISPATCH_TIME_FOREVER); \
- __VA_ARGS__; \
- dispatch_semaphore_signal(locker);
- @interface APBUtils : NSObject
- + (NSString *)MD5WithData:(NSData *)data;
- + (NSString *)randomString:(NSInteger)len;
- + (BOOL)isWifi;
- + (void)APBMainThread:(dispatch_block_t)block;
- + (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;
- + (NSString*)convertToJSONString:(NSDictionary *)infoDict;
- + (NSString *)currentLanguage;
- + (NSString *)localizedStringForKey:(NSString *)key inBundle:(NSString *)bundle;
- + (NSString *)localizedStringForKey:(NSString *)key;
- + (long long)getTotalDiskSize;
- + (long long)getAvailableDiskSize;
- + (NSString*)deviceVersion;
- + (NSString *)osVersion;
- + (NSString *)appName;
- + (NSString *)appVersion;
- + (CMVideoDimensions)maxResolution:(AVCaptureDevicePosition) position;
- @end
|