1、更加强大的Log输出
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), PRETTY_FUNCTION, LINE, ##VA_ARGS);
NSInteger numberA = 100;DLog(@"numberA is %ld",numberA);NSArray *arrayA = @[@"A",@"B",@"C"];DLog(@"arrayA is %@",arrayA);
打印的内容包括所在的类,所在的方法,所在行数。
2、布局时候使用CGRectInset,设置左右、上下边距
UIView *blackView = [[UIView alloc] initWithFrame:CGRectInset(self.view.bounds, 10, 30)];blackView.backgroundColor = [UIColor blackColor];[self.view addSubview:blackView];
3、CFAbsoluteTimeGetCurrent()计算时间差
NSTimeInterval startTime = CFAbsoluteTimeGetCurrent();NSURL *url = [NSURL URLWithString:@"http://m.weather.com.cn/atad/101280601.html"];NSData *data = [NSData dataWithContentsOfURL:url];DLog(@"data is %@",data);NSTimeInterval endTime = CFAbsoluteTimeGetCurrent();DLog(@"time gap is %f",endTime - startTime);