#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface Helpers : NSObject
@property(nonatomic,strong)NSDateFormatter *h_dateFormatter;
@property(nonatomic,strong)NSDateComponents *h_components;
+(BOOL)strIsEmty:(NSString *)str;
+(NSString *)getPathByMain:(NSString *)name
type:(NSString *)tp;
+ (NSString *)getPath:(NSString *)fileName;
+(BOOL)fileIsExit:(NSString *)path;
+(BOOL)deleteFile:(NSString *)path;
+(BOOL)dicIsExit:(NSString *)path;
+(BOOL)createFile:(NSString *)url
data:(NSData *)data;
+(BOOL)createDic:(NSString *)url;
+(NSString *)getNowStr;
+(int)getNowYear;
+(NSString *)getDateStr:(NSDate *)date;
+(NSDate *)getDateByString:(NSString *)str;
+(NSString *)getDateStrFromDate:(NSDate *)date bySeconds:(double)seconds;
+(NSDictionary *)getDateInfoForDate:(NSDate *)date;
+ (NSString *)convertToDateString:(NSDate *)date
withFormat:(NSString *)dateFormat;
+(NSString *)URLEncodedString:(NSString *)str;
+(NSString *)URLDecodedString:(NSString *)str;
+(BOOL)strIsChecked:(NSString *)str
checkStr:(NSString *)checkStr;
+(BOOL)objIsNull:(id)obj;
+(NSString *)inputStr:(id)ipStr;
+(BOOL)strIsEmail:(NSString *)targetStr;
+(BOOL)strIsMobileOrEmail:(NSString *)targetStr;
+(BOOL)strIsWordorNum:(NSString *)targetStr;
+(BOOL)strIsChinaWord:(NSString *)targetStr;
+(BOOL)strIsPassword:(NSString *)targetStr;
+(BOOL)strIsInLen:(int)tLen targetStr:(NSString *)tStr;
#pragma mark -
#pragma mark base64 string 加密以及解密
#define __BASE64( text ) [CommonFunc base64StringFromText:text]
#define __TEXT( base64 ) [CommonFunc textFromBase64String:base64]
/******************************************************************************
函数名称 : + (NSString *)base64StringFromText:(NSString *)text
函数描述 : 将文本转换为base64格式字符串
输入参数 : (NSString *)text 文本
输出参数 : N/A
返回参数 : (NSString *) base64格式字符串
备注信息 :
******************************************************************************/
+ (NSString *)base64StringFromText:(NSString *)text;
/******************************************************************************
函数名称 : + (NSString *)textFromBase64String:(NSString *)base64
函数描述 : 将base64格式字符串转换为文本
输入参数 : (NSString *)base64 base64格式字符串
输出参数 : N/A
返回参数 : (NSString *) 文本
备注信息 :
******************************************************************************/
+ (NSString *)textFromBase64String:(NSString *)base64;
//分分秒秒
+ (NSString *)timeFormattedMMSS:(int)totalSeconds;
//时时分分秒秒
+ (NSString *)timeFormattedHHMMSS:(int)totalSeconds;
//通过字典串返回cgrect
+ (CGRect )strForCgrect:(NSDictionary *)dic;
//检测首字母不能为数字,中英文
+ (BOOL)strIsIllegal:(NSString *)targetStr;
//检测手机号
+ (BOOL)strIsMobile:(NSString *)targetStr;
//判断int数是否小于10,如果小于10 拼接0~
+ (NSString *)intIsLessThanTen:(int)little;
//是否包涵空格
+ (BOOL)stringIsContainBlank:(NSString *)targetStr;
//保存数据
+ (void)nsuserDefaultSetvalueWithKey:(NSString *)key Value:(NSString *)value;
//读取数据
+ (NSString *)nsuserDefaultObjectForKeyWithKey:(NSString *)key;
@end
#import "Helpers.h"
#import <CommonCrypto/CommonCryptor.h>
#import <UIKit/UIKit.h>
static NSDateFormatter *dateFormatter = nil;
@implementation Helpers
+(BOOL)strIsEmty:(NSString *)str
{
if (str == nil || str == NULL) {
return YES;
}
if ([str isKindOfClass:[NSNull class]]) {
return YES;
}
if (str.length == 0) {
return YES;
}
return NO;
}
+(NSString *)getPathByMain:(NSString *)name
type:(NSString *)tp
{
return [[NSBundle mainBundle] pathForResource:name ofType:tp];
}
+ (NSString *)getPath:(NSString *)fileName
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return [[paths objectAtIndex:0] stringByAppendingPathComponent:fileName];
}
+(BOOL)fileIsExit:(NSString *)path
{
NSFileManager *_fm = [NSFileManager defaultManager];
BOOL _flag = NO;
if (path) {
return [_fm fileExistsAtPath:path isDirectory:&_flag];
}else{
return NO;
}
}
+(BOOL)deleteFile:(NSString *)path
{
NSFileManager *_fm = [NSFileManager defaultManager];
if (path) {
return [_fm removeItemAtPath:path error:nil];
}else{
return NO;
}
}
+(BOOL)dicIsExit:(NSString *)path
{
NSFileManager *_fm = [NSFileManager defaultManager];
if (path) {
BOOL _flag = YES;
return [_fm fileExistsAtPath:path isDirectory:&_flag];
}else{
return NO;
}
}
+(BOOL)createFile:(NSString *)url
data:(NSData *)data
{
if (url && data) {
NSFileManager *_fm = [NSFileManager defaultManager];
return [_fm createFileAtPath:url contents:data attributes:nil];
}else{
return NO;
}
}
+(BOOL)createDic:(NSString *)url
{
if (url) {
NSFileManager *_fm = [NSFileManager defaultManager];
return [_fm createDirectoryAtPath:url
withIntermediateDirectories:YES
attributes:nil
error:nil];
}else{
return NO;
}
}
+(NSString *)getDateStrFromDate:(NSDate *)date
bySeconds:(double)seconds
{
NSDateComponents *components = [[NSCalendar currentCalendar] components:
NSDayCalendarUnit |
NSMonthCalendarUnit |
NSYearCalendarUnit |
NSHourCalendarUnit |
NSMinuteCalendarUnit |
NSSecondCalendarUnit
fromDate:[NSDate dateWithTimeInterval:seconds sinceDate:date]];
return [NSString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d",
(int)[components year],
(int)[components month],
(int)[components day],
(int)[components hour],
(int)[components minute],
(int)[components second]
];
}
+(NSDictionary *)getDateInfoForDate:(NSDate *)date
{
if (date) {
NSDateComponents *components = [[NSCalendar currentCalendar] components:
NSDayCalendarUnit |
NSMonthCalendarUnit |
NSYearCalendarUnit |
NSHourCalendarUnit |
NSMinuteCalendarUnit |
NSSecondCalendarUnit |
NSWeekdayCalendarUnit
fromDate:date];
return @{
@"year":[NSString stringWithFormat:@"%04d",(int)[components year]],
@"month":[NSString stringWithFormat:@"%02d",(int)[components month]],
@"day":[NSString stringWithFormat:@"%02d",(int)[components day]],
@"hour":[NSString stringWithFormat:@"%02d",(int)[components hour]],
@"minute":[NSString stringWithFormat:@"%02d",(int)[components minute]],
@"second":[NSString stringWithFormat:@"%02d",(int)[components second]],
@"weekday":[NSString stringWithFormat:@"%d",(int)[components weekday]]
};
}
else{
return nil;
}
}
+(NSString *)getNowStr
{
NSDateComponents *components = [[NSCalendar currentCalendar] components:
NSDayCalendarUnit |
NSMonthCalendarUnit |
NSYearCalendarUnit |
NSHourCalendarUnit |
NSMinuteCalendarUnit |
NSSecondCalendarUnit
fromDate:[NSDate date]];
return [NSString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d",
(int)[components year],
(int)[components month],
(int)[components day],
(int)[components hour],
(int)[components minute],
(int)[components second]
];
}
+(int)getNowYear
{
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSYearCalendarUnit
fromDate:[NSDate date]];
return (int)[components year];
}
+(NSString *)getDateStr:(NSDate *)date
{
NSDateComponents *components = [[NSCalendar currentCalendar] components:
NSDayCalendarUnit |
NSMonthCalendarUnit |
NSYearCalendarUnit |
NSHourCalendarUnit |
NSMinuteCalendarUnit |
NSSecondCalendarUnit
fromDate:date ];
return [NSString stringWithFormat:@"%04d-%02d-%02d %02d:%02d:%02d",
(int)[components year],
(int)[components month],
(int)[components day],
(int)[components hour],
(int)[components minute],
(int)[components second]
];
}
+(NSDate *)getDateByString:(NSString *)str
{
if ( str == nil || [@"" isEqualToString:str]) {
str = @"1970-01-01 00:00:00";
}
if (!dateFormatter) {
dateFormatter = [[NSDateFormatter alloc] init];
}
[dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss"];
return [dateFormatter dateFromString:str];
}
+ (NSString *)convertToDateString:(NSDate *)date
withFormat:(NSString *)dateFormat
{
if (!dateFormatter) {
dateFormatter = [[NSDateFormatter alloc] init];
}
[dateFormatter setDateFormat:dateFormat];
// [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT{8}"]];
return [dateFormatter stringFromDate:date];
}
+(BOOL)strIsChecked:(NSString *)str
checkStr:(NSString *)checkStr
{
BOOL _flag = NO;
if (str && ![str isEqual:[NSNull null]]) {
//NSString *_checkStr = @"^[0-9]{3}$";
//@"^[0-9]+-*[0-9]+$";
NSRegularExpression *regex2 = [NSRegularExpression regularExpressionWithPattern:checkStr
options:0
error:nil];
if (regex2){//对象进行匹配
NSTextCheckingResult *result2 = [regex2 firstMatchInString:str
options:0
range:NSMakeRange(0, str.length)];
if (result2) {
_flag = YES;
}
}
}
return _flag;
}
+(NSString *)URLEncodedString:(NSString *)str
{
NSString *result = (__bridge_transfer NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)str,
NULL,
CFSTR("!*'();:@&=+$,/?%#[]"),
kCFStringEncodingUTF8);
return result;
}
+(NSString *)URLDecodedString:(NSString *)str
{
NSString *result = (__bridge_transfer NSString*)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
(CFStringRef)str,
CFSTR(""),
kCFStringEncodingUTF8);
return result;
}
+(BOOL)objIsNull:(id)obj
{
BOOL _flag = YES;
if (obj && ![obj isEqual:[NSNull null]]) {
_flag = NO;
}
return _flag;
}
+(NSString *)inputStr:(id)ipStr
{
NSString *_result = @"";
if (ipStr == nil || ipStr == NULL) {
return _result = @"";
}
if ([ipStr isKindOfClass:[NSNull class]]) {
return _result = @"";
}
if ([ipStr isKindOfClass:[NSString class]]) {
_result = ipStr;
}
if ([ipStr isKindOfClass:[NSNumber class]]) {
_result = [(NSNumber *)ipStr stringValue];
}
return _result;
}
+(BOOL)strIsMobileOrEmail:(NSString *)targetStr
{
BOOL _flag = NO;
//匹配6-15个由字母/数字组成的字符串的正则表达式:
NSString *_phoneNumRegex = @"1[0-9]{10}";
//匹配邮箱格式
NSString *_emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _phoneNumRegex];
if ([_pred evaluateWithObject:targetStr]) {
_flag = YES;
}
else{
_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _emailRegex];
if ([_pred evaluateWithObject:targetStr]) {
_flag = YES;
}
}
return _flag;
}
+ (BOOL)strIsMobile:(NSString *)targetStr
{
BOOL _flag = NO;
NSString *_phoneNum = @"1[0-9]{10}";
NSPredicate *_pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",_phoneNum];
if ([_pre evaluateWithObject:targetStr]) {
_flag = YES;
}
return _flag;
}
+ (BOOL)strIsPassword:(NSString *)targetStr
{
//长度小于等于6
if (targetStr.length < 6) {
return NO;
} else if ([targetStr rangeOfString:@"@"].length > 0){//包含特殊字符@
return NO;
} else if (targetStr.length >= 16) {//大于等于16
return NO;
} else {
return YES;
}
}
+(BOOL)strIsEmail:(NSString *)targetStr
{
BOOL _flag = NO;
//匹配邮箱格式
NSString *_emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _emailRegex];
if ([_pred evaluateWithObject:targetStr]) {
_flag = YES;
}
return _flag;
}
+(BOOL)strIsWordorNum:(NSString *)targetStr
{
BOOL _flag = NO;
NSString *_emailRegex = @"[A-Z0-9a-z\u4e00-\u9fa5]*";
NSPredicate *_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _emailRegex];
if ([_pred evaluateWithObject:targetStr]) {
_flag = YES;
}
return _flag;
}
//检测首字母不能为数字,长度不能大于12字节,中英文
+ (BOOL)strIsIllegal:(NSString *)targetStr
{
BOOL _flag = NO;
NSString *_userName = @"^[^0-9][A-Za-z0-9_\u4e00-\u9fa5]*";
NSPredicate *_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _userName];
if ([_pred evaluateWithObject:targetStr]) {
_userName = @"^[A-Za-z0-9_\u4e00-\u9fa5]*";
NSPredicate *_pre = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _userName];
if ([_pre evaluateWithObject:targetStr]) {
_flag = YES;
}
}
return _flag;
}
+(BOOL)strIsChinaWord:(NSString *)targetStr
{
BOOL _flag = NO;
NSString *_emailRegex = @"[\u4e00-\u9fa5]*";
NSPredicate *_pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", _emailRegex];
if ([_pred evaluateWithObject:targetStr]) {
_flag = YES;
}
return _flag;
}
//判断是否在多少字符之内
+(BOOL)strIsInLen:(int)tLen
targetStr:(NSString *)tStr
{
BOOL _flag = NO;
int _sLen = 0;
NSString *_tStr = [Helpers inputStr:tStr];
long l = 0;
if (![@"" isEqualToString:_tStr]) {
for (int i = 0; i < _tStr.length; i++) {
NSString *_s = [_tStr substringWithRange:NSMakeRange(i, 1)];
l = strlen([_s cStringUsingEncoding:NSUTF8StringEncoding]);
if (l == 1) {
_sLen++;
}
else if(l == 3)
{
_sLen += 2;
}
else{
_sLen = tLen + 1;
break;
}
}
}
if (_sLen <= tLen && _sLen != 0) {
_flag = YES;
}
return _flag;
}
//空字符串
#define LocalStr_None @""
static const char encodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ (NSString *)base64StringFromText:(NSString *)text
{
if (text && ![text isEqualToString:LocalStr_None]) {
//取项目的bundleIdentifier作为KEY 改动了此处
//NSString *key = [[NSBundle mainBundle] bundleIdentifier];
NSData *data = [text dataUsingEncoding:NSUTF8StringEncoding];
//IOS 自带DES加密 Begin 改动了此处
//data = [self DESEncrypt:data WithKey:key];
//IOS 自带DES加密 End
return [self base64EncodedStringFrom:data];
}
else {
return LocalStr_None;
}
}
+ (NSString *)textFromBase64String:(NSString *)base64
{
if (base64 && ![base64 isEqualToString:LocalStr_None]) {
//取项目的bundleIdentifier作为KEY 改动了此处
//NSString *key = [[NSBundle mainBundle] bundleIdentifier];
NSData *data = [self dataWithBase64EncodedString:base64];
//IOS 自带DES解密 Begin 改动了此处
//data = [self DESDecrypt:data WithKey:key];
//IOS 自带DES加密 End
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
else {
return LocalStr_None;
}
}
/******************************************************************************
函数名称 : + (NSData *)DESEncrypt:(NSData *)data WithKey:(NSString *)key
函数描述 : 文本数据进行DES加密
输入参数 : (NSData *)data
(NSString *)key
输出参数 : N/A
返回参数 : (NSData *)
备注信息 : 此函数不可用于过长文本
******************************************************************************/
+ (NSData *)DESEncrypt:(NSData *)data WithKey:(NSString *)key
{
char keyPtr[kCCKeySizeAES256+1];
bzero(keyPtr, sizeof(keyPtr));
[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
NSUInteger dataLength = [data length];
size_t bufferSize = dataLength + kCCBlockSizeAES128;
void *buffer = malloc(bufferSize);
size_t numBytesEncrypted = 0;
CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmDES,
kCCOptionPKCS7Padding | kCCOptionECBMode,
keyPtr, kCCBlockSizeDES,
NULL,
[data bytes], dataLength,
buffer, bufferSize,
&numBytesEncrypted);
if (cryptStatus == kCCSuccess) {
return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted];
}
free(buffer);
return nil;
}
/******************************************************************************
函数名称 : + (NSData *)DESEncrypt:(NSData *)data WithKey:(NSString *)key
函数描述 : 文本数据进行DES解密
输入参数 : (NSData *)data
(NSString *)key
输出参数 : N/A
返回参数 : (NSData *)
备注信息 : 此函数不可用于过长文本
******************************************************************************/
+ (NSData *)DESDecrypt:(NSData *)data WithKey:(NSString *)key
{
char keyPtr[kCCKeySizeAES256+1];
bzero(keyPtr, sizeof(keyPtr));
[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
NSUInteger dataLength = [data length];
size_t bufferSize = dataLength + kCCBlockSizeAES128;
void *buffer = malloc(bufferSize);
size_t numBytesDecrypted = 0;
CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt, kCCAlgorithmDES,
kCCOptionPKCS7Padding | kCCOptionECBMode,
keyPtr, kCCBlockSizeDES,
NULL,
[data bytes], dataLength,
buffer, bufferSize,
&numBytesDecrypted);
if (cryptStatus == kCCSuccess) {
return [NSData dataWithBytesNoCopy:buffer length:numBytesDecrypted];
}
free(buffer);
return nil;
}
/******************************************************************************
函数名称 : + (NSData *)dataWithBase64EncodedString:(NSString *)string
函数描述 : base64格式字符串转换为文本数据
输入参数 : (NSString *)string
输出参数 : N/A
返回参数 : (NSData *)
备注信息 :
******************************************************************************/
+ (NSData *)dataWithBase64EncodedString:(NSString *)string
{
if (string == nil)
[NSException raise:NSInvalidArgumentException format:nil];
if ([string length] == 0)
return [NSData data];
static char *decodingTable = NULL;
if (decodingTable == NULL)
{
decodingTable = malloc(256);
if (decodingTable == NULL)
return nil;
memset(decodingTable, CHAR_MAX, 256);
NSUInteger i;
for (i = 0; i < 64; i++)
decodingTable[(short)encodingTable[i]] = i;
}
const char *characters = [string cStringUsingEncoding:NSASCIIStringEncoding];
if (characters == NULL) // Not an ASCII string!
return nil;
char *bytes = malloc((([string length] + 3) / 4) * 3);
if (bytes == NULL)
return nil;
NSUInteger length = 0;
NSUInteger i = 0;
while (YES)
{
char buffer[4];
short bufferLength;
for (bufferLength = 0; bufferLength < 4; i++)
{
if (characters[i] == '\0')
break;
if (isspace(characters[i]) || characters[i] == '=')
continue;
buffer[bufferLength] = decodingTable[(short)characters[i]];
if (buffer[bufferLength++] == CHAR_MAX) // Illegal character!
{
free(bytes);
return nil;
}
}
if (bufferLength == 0)
break;
if (bufferLength == 1) // At least two characters are needed to produce one byte!
{
free(bytes);
return nil;
}
// Decode the characters in the buffer to bytes.
bytes[length++] = (buffer[0] << 2) | (buffer[1] >> 4);
if (bufferLength > 2)
bytes[length++] = (buffer[1] << 4) | (buffer[2] >> 2);
if (bufferLength > 3)
bytes[length++] = (buffer[2] << 6) | buffer[3];
}
bytes = realloc(bytes, length);
return [NSData dataWithBytesNoCopy:bytes length:length];
}
/******************************************************************************
函数名称 : + (NSString *)base64EncodedStringFrom:(NSData *)data
函数描述 : 文本数据转换为base64格式字符串
输入参数 : (NSData *)data
输出参数 : N/A
返回参数 : (NSString *)
备注信息 :
******************************************************************************/
+ (NSString *)base64EncodedStringFrom:(NSData *)data
{
if ([data length] == 0)
return @"";
char *characters = malloc((([data length] + 2) / 3) * 4);
if (characters == NULL)
return nil;
NSUInteger length = 0;
NSUInteger i = 0;
while (i < [data length])
{
char buffer[3] = {0,0,0};
short bufferLength = 0;
while (bufferLength < 3 && i < [data length])
buffer[bufferLength++] = ((char *)[data bytes])[i++];
// Encode the bytes in the buffer to four characters, including padding "=" characters if necessary.
characters[length++] = encodingTable[(buffer[0] & 0xFC) >> 2];
characters[length++] = encodingTable[((buffer[0] & 0x03) << 4) | ((buffer[1] & 0xF0) >> 4)];
if (bufferLength > 1)
characters[length++] = encodingTable[((buffer[1] & 0x0F) << 2) | ((buffer[2] & 0xC0) >> 6)];
else characters[length++] = '=';
if (bufferLength > 2)
characters[length++] = encodingTable[buffer[2] & 0x3F];
else characters[length++] = '=';
}
return [[NSString alloc] initWithBytesNoCopy:characters length:length encoding:NSASCIIStringEncoding freeWhenDone:YES];
}
//分分秒秒
+ (NSString *)timeFormattedMMSS:(int)totalSeconds
{
int seconds = totalSeconds % 60;
int minutes = totalSeconds / 60;
return [NSString stringWithFormat:@"%02d:%02d",minutes, seconds];
}
//时时分分秒秒
+ (NSString *)timeFormattedHHMMSS:(int)totalSeconds
{
int seconds = totalSeconds % 60;
int minutes = (totalSeconds / 60) % 60;
int hours = totalSeconds / 3600;
return [NSString stringWithFormat:@"%02d:%02d:%02d",hours, minutes, seconds];
}
//将"60_20_200_30"返回一个cgrect
+ (CGRect )strForCgrect:(NSString *)str
{
// NSMutableDictionary *_result = [@{}mutableCopy];
CGRect frame = CGRectZero;
if (str) {
NSString *_fFrameStr = str;
if (_fFrameStr) {
CGRect _fra = CGRectZero;
NSArray *_frameAry = [_fFrameStr componentsSeparatedByString:@"_"];
float _x = 0;
float _y = 0;
float _fx = 0;
float _fy = 0;
_x = [(NSString *)_frameAry[0] floatValue];
_y = [(NSString *)_frameAry[1] floatValue];
_fx = [(NSString *)_frameAry[2] floatValue];
_fy = [(NSString *)_frameAry[3] floatValue];
_fra = CGRectMake(_x, _y, _fx, _fy);
frame = _fra;
}
}
return frame;
}
//判断int数是否小于10,如果小于10 拼接0~
+ (NSString *)intIsLessThanTen:(int)little
{
NSString *resultString = @"";
if (little < 10) {
resultString = [NSString stringWithFormat:@"0%d",little];
}else
{
resultString = [NSString stringWithFormat:@"%d",little];
}
return resultString;
}
//是否包涵空格
+ (BOOL)stringIsContainBlank:(NSString *)targetStr
{
BOOL _flag = NO;
if ([targetStr containsString:@" "]) {
_flag = YES;
}else
{
_flag = NO;
}
return _flag;
}
//保存数据
+ (void)nsuserDefaultSetvalueWithKey:(NSString *)key Value:(NSString *)value
{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setValue:value forKey:key];
}
//读取数据
+ (NSString *)nsuserDefaultObjectForKeyWithKey:(NSString *)key
{
NSString *resultString = [NSString string];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
resultString = [userDefaults objectForKey:key];
return resultString;
}
@end