-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a54c26
commit 7a2b18d
Showing
11 changed files
with
237 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2.59 KB
(100%)
SuperDemo.xcworkspace/xcuserdata/tanyugang.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// TYGFileManager.h | ||
// SuperDemo | ||
// | ||
// Created by 谈宇刚 on 16/6/27. | ||
// Copyright © 2016年 TYG. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface TYGFileManager : NSObject | ||
|
||
/** 磁盘总空间 */ | ||
+(CGFloat)diskOfAllSizeMBytes; | ||
|
||
/** 获取磁盘可用空间大小 */ | ||
+ (CGFloat)diskOfFreeSizeMBytes; | ||
|
||
/** 获取指定路径下某个文件的大小 */ | ||
+ (long long)fileSizeAtPath:(NSString *)filePath; | ||
|
||
/** 获取文件夹下所有文件的大小 */ | ||
+ (long long)folderSizeAtPath:(NSString *)folderPath; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// TYGFileManager.m | ||
// SuperDemo | ||
// | ||
// Created by 谈宇刚 on 16/6/27. | ||
// Copyright © 2016年 TYG. All rights reserved. | ||
// | ||
|
||
#import "TYGFileManager.h" | ||
|
||
@implementation TYGFileManager | ||
|
||
|
||
/** 磁盘总空间 */ | ||
+(CGFloat)diskOfAllSizeMBytes{ | ||
|
||
CGFloat size = 0.0; | ||
|
||
NSError *error; | ||
NSDictionary *dic = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:&error]; | ||
if (error) { | ||
#ifdef DEBUG | ||
NSLog(@"ERROR:%@",error.localizedDescription); | ||
#endif | ||
} | ||
else{ | ||
NSNumber *number = [dic objectForKey:NSFileSystemSize]; | ||
size = [number floatValue]/1024.0/1024.0; | ||
} | ||
|
||
return size; | ||
} | ||
|
||
/** 获取磁盘可用空间大小 */ | ||
+ (CGFloat)diskOfFreeSizeMBytes{ | ||
|
||
CGFloat size = 0.0; | ||
|
||
NSError *error; | ||
NSDictionary *dic = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:&error]; | ||
if (error) { | ||
#ifdef DEBUG | ||
NSLog(@"ERROR:%@",error.localizedDescription); | ||
#endif | ||
} | ||
else{ | ||
NSNumber *number = [dic objectForKey:NSFileSystemFreeSize]; | ||
size = [number floatValue]/1024.0/1024.0; | ||
} | ||
|
||
return size; | ||
} | ||
|
||
/** 获取指定路径下某个文件的大小 */ | ||
+ (long long)fileSizeAtPath:(NSString *)filePath{ | ||
NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
if (![fileManager fileExistsAtPath:filePath]) { | ||
return 0; | ||
} | ||
|
||
return [[fileManager attributesOfItemAtPath:filePath error:nil] fileSize]; | ||
} | ||
|
||
/** 获取文件夹下所有文件的大小 */ | ||
+ (long long)folderSizeAtPath:(NSString *)folderPath{ | ||
|
||
NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
if (![fileManager fileExistsAtPath:folderPath]) { | ||
return 0; | ||
} | ||
|
||
NSString *fileName; | ||
NSEnumerator *filesEnumerator = [[fileManager subpathsAtPath:folderPath] objectEnumerator]; | ||
long long folderSize = 0; | ||
while ((fileName = [filesEnumerator nextObject]) != nil) { | ||
NSString *filePath = [folderPath stringByAppendingPathComponent:fileName]; | ||
folderSize += [self fileSizeAtPath:filePath]; | ||
} | ||
|
||
return folderSize; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,13 @@ | |
*/ | ||
+ (BOOL)isTelphoneNumber:(NSString *)telNum; | ||
|
||
/** | ||
* 固定电话号码格式 | ||
* 因为固定电话格式比较复杂,情况比较多,主要验证了以下类型 | ||
* 如:010-12345678、0912-1234567、(010)-12345678、(0912)1234567、(010)12345678、(0912)-1234567、01012345678、09121234567 | ||
*/ | ||
+(BOOL)isHomePhoneNumber:(NSString *)sting; | ||
|
||
/* | ||
* Email邮箱格式验证 | ||
* 如:[email protected]、[email protected]、[email protected] | ||
|
@@ -46,16 +53,14 @@ | |
+ (BOOL)isIDCard:(NSString *)idCardString; | ||
|
||
/** | ||
* 固定电话号码格式 | ||
* 因为固定电话格式比较复杂,情况比较多,主要验证了以下类型 | ||
* 如:010-12345678、0912-1234567、(010)-12345678、(0912)1234567、(010)12345678、(0912)-1234567、01012345678、09121234567 | ||
* 只能是中文汉字 | ||
*/ | ||
+(BOOL)isPhoneNumber:(NSString *)sting; | ||
+(BOOL)isChinese:(NSString *)sting; | ||
|
||
/** | ||
* 只能是中文汉字 | ||
* 是否含有中文汉字 | ||
*/ | ||
+(BOOL)isChinese:(NSString *)sting; | ||
+ (BOOL)isHaveChineseInString:(NSString *)string; | ||
|
||
/** | ||
* 验证银行卡号(13位 到 19位) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.