关于iOS常用的26中公共方法,可copy的代码
1. 获取磁盘总空间大小
//磁盘总空间
+ (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/1024;
} return }
//磁盘可用空间
+ (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/1024;
}
3. 获取指定路径下某个文件的大小
+ (long long)fileSizeAtPath:(NSString *)filePath{
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:filePath]) return 0;
return [[fileManager attributesOfItemAtPath:filePath error:nil] fileSize];
}
|
|
4. 获取文件夹下所有文件的大小
+ (long long)folderSizeAtPath:(NSString *)folderPath{
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:folderPath]) return 0;
NSEnumerator *filesEnumerator = [[fileManager subpathsAtPath:folderPath] objectEnumerator];
NSString *fileName;
long long folerSize = 0;
while ((fileName = [filesEnumerator nextObject]) != nil) {
NSString *filePath = [folderPath stringByAppendingPathComponent:fileName];
folerSize += [self fileSizeAtPath:filePath];
}
return folerSize;
}
5. 获取字符串(或汉字)首字母
+ (NSString *)firstCharacterWithString:(NSString *)string{
NSMutableString *str = [NSMutableString stringWithString:string];
CFStringTransform((CFMutableStringRef)str, NULL, kCFStringTransformMandarinLatin, NO);
CFStringTransform((CFMutableStringRef)str, NULL, kCFStringTransformStripDiacritics, NO);
NSString *pingyin = [str capitalizedString]; return [pingyin substringToIndex:1];
}
6. 将字符串数组按照元素首字母顺序进行排序分组
+ (NSDictionary *)dictionaryOrderByCharacterWithOriginalArray:(NSArray *)array{
if (array.count == 0) {
return nil;
}
for (id obj in array) {
if (![obj isKindOfClass:[NSString class]]) {
return nil;
}
}
UILocalizedIndexedCollation *indexedCollation = [UILocalizedIndexedCollation currentCollation];
NSMutableArray *objects = [NSMutableArray arrayWithCapacity:indexedCollation.sectionTitles.count];
//创建27个分组数组
for (int i = 0; i < indexedCollation.sectionTitles.count; i++) {
NSMutableArray *obj = [NSMutableArray array];
[objects addObject:obj];
}
NSMutableArray *keys = [NSMutableArray arrayWithCapacity:objects.count];
//按字母顺序进行分组
NSInteger lastIndex = -1;
for (int i = 0; i < array.count; i++) {
NSInteger index = [indexedCollation sectionForObject:array[i] collationStringSelector:@selector(uppercaseString)];
[[objects objectAtIndex:index] addObject:array[i]];
lastIndex = index;
}
//去掉空数组
for (int i = 0; i < objects.count; i++) {
NSMutableArray *obj = objects[i];
if (obj.count == 0) {
[objects removeObject:obj];
}
}
//获取索引字母
for (NSMutableArray *obj in objects) {
NSString *str = obj[0];
NSString *key = [self firstCharacterWithString:str];
[keys addObject:key];
}
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
[dic setObject:objects forKey:keys];
return dic;
}
//获取字符串(或汉字)首字母
+ (NSString *)firstCharacterWithString:(NSString *)string{
NSMutableString *str = [NSMutableString stringWithString:string];
CFStringTransform((CFMutableStringRef)str, NULL, kCFStringTransformMandarinLatin, NO);
CFStringTransform((CFMutableStringRef)str, NULL, kCFStringTransformStripDiacritics, NO);
NSString *pingyin = [str capitalizedString]; return [pingyin substringToIndex:1];
}
使用如下:
NSArray *arr = @[@"guangzhou", @"shanghai", @"北京", @"henan", @"hainan"];
NSDictionary *dic = [Utilities dictionaryOrderByCharacterWithOriginalArray:arr]
;NSLog(@"\n\ndic: %@", dic);
7. 获取当前时间//获取当前时间//format: @"yyyy-MM-dd HH:mm:ss"、@"yyyy年MM月dd日 HH时mm分ss秒"
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:format];
return [dateFormatter stringFromDate:[NSDate date]];
}
8. 计算上次日期距离现在多久, 如 xx 小时前、xx 分钟前等
* @param lastTime 上次日期(需要和格式对应)
* @param format1 上次日期格式
* @param currentTime 最近日期(需要和格式对应)
* @param format2 最近日期格式 *
* @return xx分钟前、xx小时前、xx天前
*/
+ (NSString *)timeIntervalFromLastTime:(NSString *)lastTime lastTimeFormat:(NSString *)format1 ToCurrentTime:(NSString *)currentTime currentTimeFormat:(NSString *)format2{
//上次时间
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc]init];
dateFormatter1.dateFormat = format1;
NSDate *lastDate = [dateFormatter1 dateFromString:lastTime];
//当前时间
NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc]init];
dateFormatter2.dateFormat = format2;
NSDate *currentDate = [dateFormatter2 dateFromString:currentTime];
return [Utilities timeIntervalFromLastTime:lastDate ToCurrentTime:currentDate];
}
+ (NSString *)timeIntervalFromLastTime:(NSDate *)lastTime ToCurrentTime:(NSDate *)currentTime{
NSTimeZone *timeZone = [NSTimeZone systemTimeZone];
//上次时间
NSDate *lastDate = [lastTime dateByAddingTimeInterval:[timeZone secondsFromGMTForDate:lastTime]];
//当前时间
NSDate *currentDate = [currentTime dateByAddingTimeInterval:[timeZone secondsFromGMTForDate:currentTime]];
//时间间隔
NSInteger intevalTime = [currentDate timeIntervalSinceReferenceDate] - [lastDate timeIntervalSinceReferenceDate];
//秒、分、小时、天、月、年
NSInteger minutes = intevalTime / 60;
NSInteger hours = intevalTime / 60 / 60;
NSInteger day = intevalTime / 60 / 60 / 24;
NSInteger month = intevalTime / 60 / 60 / 24 / 30;
NSInteger yers = intevalTime / 60 / 60 / 24 / 365;
if (minutes <= 10) {
return @"刚刚";
}else if (minutes < 60){
return [NSString stringWithFormat: @"%ld分钟前",(long)minutes];
}else if (hours < 24){
return [NSString stringWithFormat: @"%ld小时前",(long)hours];
}else if (day < 30){
return [NSString stringWithFormat: @"%ld天前",(long)day];
}else if (month < 12){
NSDateFormatter * df =[[NSDateFormatter alloc]init];
df.dateFormat = @"M月d日";
NSString * time = [df stringFromDate:lastDate];
return time;
}else if (yers >= 1){
NSDateFormatter * df =[[NSDateFormatter alloc]init];
df.dateFormat = @"yyyy年M月d日";
NSString * time = [df stringFromDate:lastDate];
return time;
}
return @"";
}
使用如下:
|
1
2
3
4
|
NSLog(@"\n\nresult: %@",[Utilities timeIntervalFromLastTime:@"2015年12月8日 15:50"
lastTimeFormat:@"yyyy年MM月dd日 HH:mm"
ToCurrentTime:@"2015/12/08 16:12"
currentTimeFormat:@"yyyy/MM/dd HH:mm"]);
|
9. 判断手机号码格式是否正确
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
//判断手机号码格式是否正确
+ (BOOL)valiMobile:(NSString*)mobile{
mobile= [mobile stringByReplacingOccurrencesOfString:@" " withString:@""];
if(mobile.length!= 11)
{
returnNO;
}else{
/**
* 移动号段正则表达式
*/
NSString*CM_NUM =@"^((13[4-9])|(147)|(15[0-2,7-9])|(178)|(18[2-4,7-8]))\\d{8}|(1705)\\d{7}$";
/**
* 联通号段正则表达式
*/
NSString*CU_NUM =@"^((13[0-2])|(145)|(15[5-6])|(176)|(18[5,6]))\\d{8}|(1709)\\d{7}$";
/**
* 电信号段正则表达式
*/
NSString*CT_NUM =@"^((133)|(153)|(177)|(18[0,1,9]))\\d{8}$";
NSPredicate*pred1 =[NSPredicate predicateWithFormat:@"SELF MATCHES %@",CM_NUM];
BOOLisMatch1 =[pred1 evaluateWithObject:mobile];
NSPredicate*pred2 =[NSPredicate predicateWithFormat:@"SELF MATCHES %@",CU_NUM];
BOOLisMatch2 =[pred2 evaluateWithObject:mobile];
NSPredicate*pred3 =[NSPredicate predicateWithFormat:@"SELF MATCHES %@",CT_NUM];
BOOLisMatch3 =[pred3 evaluateWithObject:mobile];
if(isMatch1|| isMatch2|| isMatch3){
returnYES;
}else{
returnNO;
}
}
}
|
10. 判断邮箱格式是否正确
|
1
2
3
4
5
6
|
//利用正则表达式验证
+ (BOOL)isAvailableEmail:(NSString*)email{
NSString*emailRegex =@"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate*emailTest =[NSPredicate predicateWithFormat:@"SELF MATCHES %@",emailRegex];
return[emailTest evaluateWithObject:email];
}
|
11. 将十六进制颜色转换为 UIColor 对象
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
//将十六进制颜色转换为 UIColor 对象
+ (UIColor*)colorWithHexString:(NSString*)color{
NSString*cString =[[color stringByTrimmingCharactersInSet:[NSCharacterSetwhitespaceAndNewlineCharacterSet]] uppercaseString];
// String should be 6 or 8 characters
if([cStringlength]< 6){
return[UIColorclearColor];
}
// strip "0X" or "#" if it appears
if([cString hasPrefix:@"0X"])
cString= [cString substringFromIndex:2];
if([cString hasPrefix:@"#"])
cString= [cString substringFromIndex:1];
if([cStringlength]!= 6)
return[UIColorclearColor];
// Separate into r, g, b substrings
NSRangerange;
range.location= 0;
range.length= 2;
//r
NSString*rString =[cString substringWithRange:range];
//g
range.location= 2;
NSString*gString =[cString substringWithRange:range];
//b
range.location= 4;
NSString*bString =[cString substringWithRange:range];
// Scan values
unsignedint r,g,b;
[[NSScanner scannerWithString:rString] scanHexInt:&r];
[[NSScanner scannerWithString:gString] scanHexInt:&g];
[[NSScanner scannerWithString:bString] scanHexInt:&b];
return[UIColor colorWithRed:((float)r /255.0f) green:((float)g /255.0f) blue:((float)b /255.0f) alpha:1.0f];
}
|
12. 对图片进行滤镜处理
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#pragma mark - 对图片进行滤镜处理
// 怀旧 --> CIPhotoEffectInstant 单色 --> CIPhotoEffectMono
// 黑白 --> CIPhotoEffectNoir 褪色 --> CIPhotoEffectFade
// 色调 --> CIPhotoEffectTonal 冲印 --> CIPhotoEffectProcess
// 岁月 --> CIPhotoEffectTransfer 铬黄 --> CIPhotoEffectChrome
// CILinearToSRGBToneCurve, CISRGBToneCurveToLinear, CIGaussianBlur, CIBoxBlur, CIDiscBlur, CISepiaTone, CIDepthOfField
+(UIImage*)filterWithOriginalImage:(UIImage*)image filterName:(NSString*)name{
CIContext*context =[CIContext contextWithOptions:nil];
CIImage*inputImage =[[CIImagealloc] initWithImage:image];
CIFilter*filter =[CIFilter filterWithName:name];
[filter setValue:inputImage forKey:kCIInputImageKey];
CIImage*result =[filter valueForKey:kCIOutputImageKey];
CGImageRefcgImage =[context createCGImage:result fromRect:[resultextent]];
UIImage*resultImage =[UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
returnresultImage;
}
|
13. 对图片进行模糊处理
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#pragma mark - 对图片进行模糊处理
// CIGaussianBlur ---> 高斯模糊
// CIBoxBlur ---> 均值模糊(Available in iOS 9.0 and later)
// CIDiscBlur ---> 环形卷积模糊(Available in iOS 9.0 and later)
// CIMedianFilter ---> 中值模糊, 用于消除图像噪点, 无需设置radius(Available in iOS 9.0 and later)
// CIMotionBlur ---> 运动模糊, 用于模拟相机移动拍摄时的扫尾效果(Available in iOS 9.0 and later)
+(UIImage*)blurWithOriginalImage:(UIImage*)image blurName:(NSString*)name radius:(NSInteger)radius{
CIContext*context =[CIContext contextWithOptions:nil];
CIImage*inputImage =[[CIImagealloc] initWithImage:image];
CIFilter*filter;
if(name.length!= 0){
filter= [CIFilter filterWithName:name];
[filter setValue:inputImage forKey:kCIInputImageKey];
if(![name isEqualToString:@"CIMedianFilter"]){
[filter setValue:@(radius) forKey:@"inputRadius"];
}
CIImage*result =[filter valueForKey:kCIOutputImageKey];
CGImageRefcgImage =[context createCGImage:result fromRect:[resultextent]];
UIImage*resultImage =[UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
returnresultImage;
}else{
returnnil;
}
}
|
14. 调整图片饱和度、亮度、对比度
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/**
* 调整图片饱和度, 亮度, 对比度
*
* @param image 目标图片
* @param saturation 饱和度
* @param brightness 亮度: -1.0 ~ 1.0
* @param contrast 对比度
*
*/
+ (UIImage*)colorControlsWithOriginalImage:(UIImage*)image
saturation:(CGFloat)saturation
brightness:(CGFloat)brightness
contrast:(CGFloat)contrast{
CIContext*context =[CIContext contextWithOptions:nil];
CIImage*inputImage =[[CIImagealloc] initWithImage:image];
CIFilter*filter =[CIFilter filterWithName:@"CIColorControls"];
[filter setValue:inputImage forKey:kCIInputImageKey];
[filter setValue:@(saturation) forKey:@"inputSaturation"];
[filter setValue:@(brightness) forKey:@"inputBrightness"];
[filter setValue:@(contrast) forKey:@"inputContrast"];
CIImage*result =[filter valueForKey:kCIOutputImageKey];
CGImageRefcgImage =[context createCGImage:result fromRect:[resultextent]];
UIImage*resultImage =[UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
returnresultImage;
}
|
15. 创建一张实时模糊效果 View (毛玻璃效果)
|
1
2
3
4
5
6
7
|
//Avilable in iOS 8.0 and later
+ (UIVisualEffectView*)effectViewWithFrame:(CGRect)frame{
UIBlurEffect*effect =[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView*effectView =[[UIVisualEffectViewalloc] initWithEffect:effect];
effectView.frame= frame;
returneffectView;
}
|
16. 全屏截图
|
1
2
3
4
5
6
7
8
9
|
//全屏截图
+ (UIImage*)shotScreen{
UIWindow*window =[UIApplicationsharedApplication].keyWindow;
UIGraphicsBeginImageContext(window.bounds.size);
[window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage*image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
returnimage;
}
|
17. 截取一张 view 生成图片
|
1
2
3
4
5
6
7
8
|
//截取view生成一张图片
+ (UIImage*)shotWithView:(UIView*)view{
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage*image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
returnimage;
}
|
18. 截取view中某个区域生成一张图片
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
//截取view中某个区域生成一张图片
+ (UIImage*)shotWithView:(UIView*)view scope:(CGRect)scope{
CGImageRefimageRef =CGImageCreateWithImageInRect([self shotWithView:view].CGImage,scope);
UIGraphicsBeginImageContext(scope.size);
CGContextRefcontext =UIGraphicsGetCurrentContext();
CGRectrect =CGRectMake(0,0,scope.size.width,scope.size.height);
CGContextTranslateCTM(context,0,rect.size.height);//下移
CGContextScaleCTM(context,1.0f,-1.0f);//上翻
CGContextDrawImage(context,rect,imageRef);
UIImage*image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGImageRelease(imageRef);
CGContextRelease(context);
returnimage;
}
|
19. 压缩图片到指定尺寸大小
|
1
2
3
4
5
6
7
8
|
//压缩图片到指定尺寸大小
+ (UIImage*)compressOriginalImage:(UIImage*)image toSize:(CGSize)size{
UIImage*resultImage =image;
UIGraphicsBeginImageContext(size);
[resultImage drawInRect:CGRectMake(0,0,size.width,size.height)];
UIGraphicsEndImageContext();
returnresultImage;
}
|
20. 压缩图片到指定文件大小
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
//压缩图片到指定文件大小
+ (NSData*)compressOriginalImage:(UIImage*)image toMaxDataSizeKBytes:(CGFloat)size{
NSData*data =UIImageJPEGRepresentation(image,1.0);
CGFloatdataKBytes =data.length/1000.0;
CGFloatmaxQuality =0.9f;
CGFloatlastData =dataKBytes;
while(dataKBytes> size&& maxQuality> 0.01f){
maxQuality= maxQuality- 0.01f;
data= UIImageJPEGRepresentation(image,maxQuality);
dataKBytes= data.length/1000.0;
if(lastData== dataKBytes){
break;
}else{
lastData= dataKBytes;
}
}
returndata;
}
|
21. 获取设备 IP 地址
需要先引入下头文件:
|
1
2
|
#import <ifaddrs.h>
#import <arpa/inet.h>
|
代码:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
//获取设备 IP 地址
+ (NSString*)getIPAddress{
NSString*address =@"error";
structifaddrs *interfaces= NULL;
structifaddrs *temp_addr= NULL;
intsuccess =0;
success= getifaddrs(&interfaces);
if(success== 0){
temp_addr= interfaces;
while(temp_addr!= NULL){
if(temp_addr->ifa_addr->sa_family== AF_INET){
if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]){
address= [NSString stringWithUTF8String:inet_ntoa(((structsockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
}
}
temp_addr= temp_addr->ifa_next;
}
}
freeifaddrs(interfaces);
returnaddress;
}
|
22. 判断字符串中是否含有空格
|
1
2
3
4
5
6
7
8
|
+(BOOL)isHaveSpaceInString:(NSString*)string{
NSRange_range =[string rangeOfString:@" "];
if(_range.location!= NSNotFound){
returnYES;
}else{
returnNO;
}
}
|
23. 判断字符串中是否含有某个字符串
|
1
2
3
4
5
6
7
8
|
+(BOOL)isHaveString:(NSString*)string1 InString:(NSString*)string2{
NSRange_range =[string2 rangeOfString:string1];
if(_range.location!= NSNotFound){
returnYES;
}else{
returnNO;
}
}
|
24. 判断字符串中是否含有中文
|
1
2
3
4
5
6
7
8
9
|
+(BOOL)isHaveChineseInString:(NSString*)string{
for(NSIntegeri =0;i <[string length];i++){
inta =[string characterAtIndex:i];
if(a> 0x4e00&& a< 0x9fff){
returnYES;
}
}
returnNO;
}
|
25. 判断字符串是否全部为数字
|
1
2
3
4
5
6
7
8
9
10
|
+(BOOL)isAllNum:(NSString*)string{
unicharc;
for(inti=0;i<string.length;i++){
c=[string characterAtIndex:i];
if(!isdigit(c)){
returnNO;
}
}
returnYES;
}
|
26. 绘制虚线
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/*
** lineFrame: 虚线的 frame
** length: 虚线中短线的宽度
** spacing: 虚线中短线之间的间距
** color: 虚线中短线的颜色
*/
+(UIView*)createDashedLineWithFrame:(CGRect)lineFrame
lineLength:(int)length
lineSpacing:(int)spacing
lineColor:(UIColor*)color{
UIView*dashedLine =[[UIViewalloc] initWithFrame:lineFrame];
dashedLine.backgroundColor= [UIColorclearColor];
CAShapeLayer*shapeLayer =[CAShapeLayerlayer];
[shapeLayer setBounds:dashedLine.bounds];
[shapeLayer setPosition:CGPointMake(CGRectGetWidth(dashedLine.frame)/ 2,CGRectGetHeight(dashedLine.frame))];
[shapeLayer setFillColor:[UIColorclearColor].CGColor];
[shapeLayer setStrokeColor:color.CGColor];
[shapeLayer setLineWidth:CGRectGetHeight(dashedLine.frame)];
[shapeLayer setLineJoin:kCALineJoinRound];
[shapeLayer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:length],[NSNumber numberWithInt:spacing],nil]];
CGMutablePathRefpath =CGPathCreateMutable();
CGPathMoveToPoint(path,NULL,0,0);
CGPathAddLineToPoint(path,NULL,CGRectGetWidth(dashedLine.frame),0);
[shapeLayer setPath:path];
CGPathRelease(path);
[dashedLine.layer addSublayer:shapeLayer];
returndashedLine
|
关于iOS常用的26中公共方法,可copy的代码的更多相关文章
- Python_Selenium 之以login_page为例实现对basepage封装好的方法调用和对common中公共方法的调用
目的:简化代码,提供框架该有的东西每一个函数 -提供了一个功能 - 公共的功能有了basepage,在PageObjects当中直接调用元素操作. 以下以login_page 为例,实现从配置文件中读 ...
- Java中的equals和==的区别以及几个常用的object中的方法简单的调试方法
一.equals 1.equals:是Object类中的方法,只能判断引用类型 2.默认判断的是地址是否相等(判断两个参数是否是同一个对象),子类中往往重写该方法,用于判断内容(值)是否相等 二.== ...
- iOS之NSString类中compare方法的陷阱
typedef NS_ENUM(NSInteger, NSComparisonResult) {NSOrderedAscending = -1L, NSOrderedSame, NSOrderedDe ...
- 前端项目中公共方法汇总utils.js
目录 判断手机类型IOS Android 格式化金钱 金钱字符串变回数字 用aa替换中文 并返回 去除文件后缀,得到文件名称(不带后缀) 获取浏览器类型(名称) post方式下载文件流 动态设置img ...
- IOS - 常用宏定义和功能方法
可能不定期添加新的东西 github地址:https://github.com/yuqingzhude/CommonUseDemo /************************Tools**** ...
- js常用的2中排序方法:冒泡排序和快速排序
冒泡排序:例如9 4 5 6 8 3 2 7 10 1 首先:9和4比较 4放前 4 9 5 6 8 3 2 7 10 1 4和5比较 4不动 4 9 5 6 8 3 2 7 10 1 ...
- go中的方法以及自定义类型代码示例
package main import "fmt" type user struct { name string age int sex string } type admin s ...
- iOS常用公共方法
iOS常用公共方法 字数2917 阅读3070 评论45 喜欢236 1. 获取磁盘总空间大小 //磁盘总空间 + (CGFloat)diskOfAllSizeMBytes{ CGFloat si ...
- iOS 常用公共方法
iOS常用公共方法 1. 获取磁盘总空间大小 //磁盘总空间 + (CGFloat)diskOfAllSizeMBytes{ CGFloat size = 0.0; NSError *error; N ...
随机推荐
- Java中使用CountDownLatch进行多线程同步
CountDownLatch介绍 在前面的Java学习笔记中,总结了Java中进行多线程同步的几个方法: 1.synchronized关键字进行同步. 2.Lock锁接口及其实现类ReentrantL ...
- 20160223.CCPP体系详解(0033天)
程序片段(01):MyArray.h+MyArray.c+main.c 内容概要:数组库 ///MyArray.h #pragma once #define DT int//类型通用 typedef ...
- Dynamics CRM2016 Web Api之时间字段值的处理
本篇又是一次来谈到CRM中时间字段的问题,那这次要谈的是在引用web api过程中写代码上的注意事项,常用的代码场景即JS和c#. 先来看下js,从下图中可以看到,我直接将new Date()赋值给时 ...
- Unity3d导出场景地图寻路
Unity3d导出场景地图寻路(金庆的专栏)Unity3d中用无渲染的透明盒子摆出地面和阻档区域. this.renderer.enabled = false;所有这些盒子设为Navig ...
- [virtualenv]生产环境中使用virtualenv
virtualenv 对于python开发和部署都是好工具,可以隔离多个python版本和第三方库的版本,这里作者总结了几个常用python服务怎么样结合virtual部署 原文链接 Python 中 ...
- DBoW2算法原理介绍
本篇介绍DBoW2算法原理介绍,下篇介绍DBoW2的应用. DBow2算法 DBow2是一种高效的回环检测算法,DBOW2算法的全称为Bags of binary words for fast pla ...
- Mac版Android Studio的安装和使用
Android Studio已经出来很长时间了,据说谷歌会逐步放弃对Eclipse的支持,而把心思完全放在Android Studio上,鉴于Eclipse的各种不稳定,或许这将成一种趋势,因此,没事 ...
- 5.3、Android Studio录像
Android Monitor允许你从设备中录制一段MP4格式的视频,最长允许3分钟. 录制视频 在硬件设备中录制视频: 1. 打开一个项目 2. 在设备中运行应用 3. 显示Android Moni ...
- [ExtJS5学习笔记]第七节 Extjs5的组件components及其模板事件方法学习
本文地址:http://blog.csdn.net/sushengmiyan/article/details/38487519 本文作者:sushengmiyan ------------------ ...
- 【移动开发】自定义ProgressBar
<ProgressBar android:layout_centerInParent="true" android:layout_width="30dp" ...