iOS 代码的抽取方式

编程思想:低耦合,高聚合(代码聚合,方便去管理)
函数式编程思想(高聚合):把很多功能放在一个函数块(block块)去处理

  1. 利用方法进行抽取代码,把某个模块放到一个方法中。利用[self methodName];

2.函数式

UICollectionView *collectionV = ({
       
       UICollectionView *collectionV = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 200, SCREEN_WIDTH, 200) collectionViewLayout:layout];
       collectionV.backgroundColor = [UIColor brownColor];
       collectionV.dataSource = self;
      
       [self.view addSubview:collectionV];
       collectionV;
   });

Class *obi = ({
Class *obj =[ [Class alloc] init] ;
obj
});
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容