这里向各位推荐一些简单常用的代码块
1.添加警告信息
#warning <#message#>
2.忽略 performSeletor 方法内存泄漏提醒
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
3.Masonry 省略前缀mas_ 的宏命令
/**
第三方框架 : Masonry
*/
//define this constant if you want to use Masonry without the 'mas_' prefix
#define MAS_SHORTHAND
//define this constant if you want to enable auto-boxing for default syntax
#define MAS_SHORTHAND_GLOBALS
// 导入头文件
#import "Masonry.h"
4.打标记
#pragma mark <#message#>
- 获取主队列
dispatch_async(dispatch_get_main_queue(), ^{
<#code#>
});
6.获取全局并发队列
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
<#code#>
});
- 代理属性
@property (nonatomic,weak) id<<#protocol#>> <#delegate#>;
8.block 属性
@property (nonatomic,copy) <#Block#> <#block#>;
- afterGCD
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(<#delayInSeconds#> * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
<#code to be executed after a specified delay#>
});
- weak 属性
@property (nonatomic, weak) <#type#> *<#name#>;
11.strong属性
@property (nonatomic,strong) <#type#> *<#name#>;
12.assign 属性
@property (nonatomic,assign) <#type#> <#name#>;
13.copy 属性
@property (nonatomic,copy) <#type#> *<#name#>;