iOS常用代码块Snippets
2019-08-23 本文已影响0人
加盐白咖啡
属性
- strong-pstrong
/** <#注释#> */
@property (nonatomic, strong) <#Class#> *<#name#>;
- weak-pweak
/** <#注释#> */
@property(nonatomic, weak) <#Class#> *<#name#>;
- copy-pcopy
/** <#注释#> */
@property (nonatomic, copy) NSString *<#string#>;
- assign-passign
/** <#注释#> */
@property (nonatomic, assign) <#Class#> <#name#>;
- block1-pblock1
/** <#注释#> */
@property(nonatomic, copy) void(^<#name#>)(<#type#> <#name#>);
- block2-pblock2
/** <#注释#> */
@property(nonatomic, copy) <#MyBlock#> <#blockName#>;
- delegate-pdelegate
/** <#注释#> */
@property(nonatomic, weak) id<<#delegatename#>> delegate;
- BOOL-pbool
/** <#注释#> */
@property(nonatomic, assign) BOOL <#name#>;
mark
- life生命区域-plife
#pragma mark - life生命区
- lazy懒加载-plazy
#pragma mark - lazy懒加载
- 通用-pmark
#pragma mark - <#内容#>
枚举值
- 枚举-penum
typedef NS_ENUM(NSUInteger, <#MyEnum#>) {
<#MyEnumValueA#>,
<#MyEnumValueB#>,
<#MyEnumValueC#>,
};
alert提示框
- alert-palert
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[alert addAction:cancleAction];
[alert addAction:sureAction];
[self presentViewController:alert animated:YES completion:nil];
迁移快捷代码
-
打开终端输入: open ~/Library/Developer/Xcode/UserData/CodeSnippets(如果没有CodeSnippets 可以先自定义一个代码段,然后文件自动生成)
image.png