iOS 项目优化

/1.数据获取下载(特别是大数据)最好放在global_queue中操作
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  
});
 
//2.UI更新放在main_queue中更新(不管当前线程是否处于主线程)
dispatch_async(dispatch_get_main_queue(), ^(void) {
          [yourTableView reloadData];
         });
//使用Block 语法是,应注意self 的循环应用导致的一些问题(如 无法dealloc等)
使用   __weak __typeof(self) weakSelf = self或 __weak XxxViewController *weakSelf = self;
 
4.图片加载使用,大图使用 方法2或3
//方法1  如果使用这种方式加载,只要程序不退出,它便一直会在内存中。只需加载一次,它便在内存中,所以第二次加载速度很快。
UIImage *imag1 = [UIImage imageNamed:@"image.png"];  
//方法2     这种加载方式由于我们将它释放掉了,会再次加载。
UIImage *image2 = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image.png" ofType:nil]];  
//方法3  
NSData *imageData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"image.png" ofType:nil]];  
UIImage *image3 = [UIImage imageWithData:imageData];  
UIImage  *image=[UIImage imageWithContentsOfFile:@"file://doucment/image.png"];
//七牛图片一些小的头像使用用缩略图
 
5,大量UI及数据时使用懒加载方式加载
 
 
 
 
原文地址:https://www.cnblogs.com/hl666/p/4346652.html