This file contains hidden or 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
//十六进制转ASCII | |
-(int )HexConvertToASCII:(NSString *)hexString{ | |
int j=0; | |
int data = 0; | |
for(int i=0;i<[hexString length];i++) | |
{ | |
int int_ch; /// 两位16进制数转化后的10进制数 | |
unichar hex_char1 = [hexString characterAtIndex:i]; ////两位16进制数中的第一位(高位*16) | |
This file contains hidden or 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
+ (NSString *)TimerString:(float)fTimer | |
{ | |
int iHour = fTimer / 3600; | |
float fMinute = fTimer - (iHour * 3600); | |
int iMinute = fMinute / 60; | |
int iSecond = fMinute - (iMinute * 60); | |
if (iHour != 0) | |
{ | |
return [NSString stringWithFormat:@"%.2d:%.2d:%.2d", iHour, iMinute, iSecond]; |
This file contains hidden or 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
- (NSTimeInterval)benchmark:(void (^)(void))block | |
{ | |
NSParameterAssert(block != NULL); | |
NSDate *start = [NSDate date]; | |
block(); | |
return [[NSDate date] timeIntervalSinceDate:start]; | |
} |
This file contains hidden or 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
// 方法1:使用unix c函数来实现获取文件大小,速度超快 | |
float Utils::getFileSizeAtPath(NSString* filePath) | |
{ | |
if (filePath == nil || [filePath length] == 0) | |
{ | |
return 0; | |
} | |
struct stat st; | |
if(lstat([filePath cStringUsingEncoding:NSUTF8StringEncoding], &st) == 0){ | |
return st.st_size; |
This file contains hidden or 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
NSArray* obtainAllFilesName(NSString *directoryString) | |
{ | |
NSFileManager *temFM = [NSFileManager defaultManager];//创建文件管理器 | |
if (directoryString) | |
{ | |
NSArray *temFilesArray = [temFM subpathsAtPath:directoryString];//获取该目录下的所有文件名 | |
return temFilesArray; | |
} | |
else | |
return nil; |
This file contains hidden or 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
- (void)textViewDidChange:(UITextView *)textView | |
{ NSRange textRange = [textView selectedRange]; | |
[textView setText:[self disable_emoji:[textView text]]]; | |
[textView setSelectedRange:textRange]; | |
} | |
This file contains hidden or 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
- (void)viewDidLoad | |
{ | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillShow:) | |
name:UIKeyboardWillShowNotification | |
object:nil]; | |
} | |
- (void)keyboardWillShow:(NSNotification*)aNotification | |
{ |
This file contains hidden or 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
@interface ExtendedHitButton: UIButton | |
+ (instancetype) extendedHitButton; | |
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event; | |
@end | |
@implementation ExtendedHitButton |
This file contains hidden or 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
+ (UIImage *)imageWithMaxSide:(CGFloat)length sourceImage:(UIImage *)image | |
{ | |
CGFloat scale = [[UIScreen mainScreen] scale]; | |
CGSize imgSize = CWSizeReduce(image.size, length); | |
UIImage *img = nil; | |
UIGraphicsBeginImageContextWithOptions(imgSize, YES, scale); // 创建一个 bitmap context | |
[image drawInRect:CGRectMake(0, 0, imgSize.width, imgSize.height) | |
blendMode:kCGBlendModeNormal alpha:1.0]; // 将图片绘制到当前的 context 上 |
This file contains hidden or 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
CFArrayRef myArray = CNCopySupportedInterfaces(); | |
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0)); | |
+ (NSString *)GetCurrentWifiHotSpotName | |
{ | |
NSString *wifiName = nil; | |
NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces(); | |
for (NSString *ifnam in ifs) | |
{ |
NewerOlder