iOS常用代码块

这里向各位推荐一些简单常用的代码块

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#>
  1. 获取主队列
dispatch_async(dispatch_get_main_queue(), ^{
        <#code#>
    });

6.获取全局并发队列

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        <#code#>
    });
  1. 代理属性
@property (nonatomic,weak) id<<#protocol#>> <#delegate#>;

8.block 属性

@property (nonatomic,copy) <#Block#> <#block#>;
  1. 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#>
    });
  1. 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#>;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值