iOS开发小技巧总结20150318

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);

《iOS开发小技巧总结20150318》
打印的内容包括所在的类,所在的方法,所在行数。

2、布局时候使用CGRectInset,设置左右、上下边距

UIView *blackView = [[UIView alloc] initWithFrame:CGRectInset(self.view.bounds, 10, 30)];
blackView.backgroundColor = [UIColor blackColor];
[self.view addSubview:blackView];

《iOS开发小技巧总结20150318》

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);

《iOS开发小技巧总结20150318》

4、

    原文作者:leejan97
    原文地址: https://segmentfault.com/a/1190000002605672
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞