簡(jiǎn)潔快捷的代碼塊能極大地提高開(kāi)發(fā)效率
屬性注釋 快捷鍵:xx
/** <#屬性注釋#> */
多行注釋 快捷鍵:zz
/** <#簡(jiǎn)要描述#>
* <#詳細(xì)描述#>
*/
#pragma mark ——- 快捷鍵:mark-
#pragma mark ——— <#mark#>
#pragma mark — 快捷鍵:mark
#pragma mark — <#mark#>
weak屬性創(chuàng)建 快捷鍵:weak
/** <#weak屬性注釋#> */
@property (nonatomic, weak) <#Class#> *<#name#>;
copy屬性創(chuàng)建 快捷鍵:copy
/** <#copy屬性注釋#> */
@property (nonatomic, copy) NSString *<#name#>;
assign屬性創(chuàng)建 快捷鍵: assign
/** <#assign屬性注釋#> */
@property (nonatomic, assign) <#Class#> <#name#>;
UIAlertViewController創(chuàng)建
// UIAlertViewController(彈框視圖)
UIAlertController *<#alert#> = [UIAlertController alertControllerWithTitle:<#title#> message:<#message#> preferredStyle:<#UIAlertControllerStyle#>];
UIAlertAction *<#action#> = [UIAlertAction actionWithTitle:<#@"確定"#> style:<#UIAlertActionStyle#> handler:<#^(UIAlertAction * _Nonnull action)handler#>];
[alert addAction:<#action#>];
[self presentViewController:<#alert#> animated:<#(BOOL)#> completion:<#^(void)completion#>];
懶加載
#pragma mark - 懶加載
- (<#type#> *)<#name#> {
if (!_<#name#>) {
_<#name#> = <#statements#>;
}
return _<#name#>;
}
一個(gè)頁(yè)面多個(gè)請(qǐng)求
dispatch_group_t group = dispatch_group_create();
dispatch_group_enter(group);
[^{
dispatch_group_leave(group);
}];
dispatch_group_enter(group);
[^{
dispatch_group_leave(group);
}];
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
});
代理.h 快捷鍵:delegate.h
@protocol <#LoginViewControllerDelegate#> <NSObject>
@required // 必須實(shí)現(xiàn)的方法 默認(rèn)
@optional // 可選實(shí)現(xiàn)的方法
- (void)<#loginViewControllerDidSuccess#>:(<#Class#> *)<#obj#>;
@end
@property(nonatomic, weak) id<<#LoginViewControllerDelegate#>> <#代理屬性#>;
代理.m 快捷鍵:delegate.m
//成功后的回調(diào)
if ([self.<#代理屬性#> respondsToSelector:@selector(<#代理方法名loginViewControllerDidSuccess#>:)]) {
[self.<#代理屬性#> <#代理方法名loginViewControllerDidSuccess#>:<#obj#>];
}
屬性block.h 快捷鍵:blockProperty.h
// <#屬性block#>
@property (nonatomic, copy) void(^<#nameBlock#>)(<#Class#> *<#obj#>);
屬性block.m 快捷鍵:blockProperty.m
if (self.<#nameBlock#>) {
self.<#nameBlock#>(<#obj#>);
}
方法block.h 快捷鍵:blockMethod.h
typedef void(^<#AYHandle#>)(<#Class#> *<#obj#>);
- (void)<#block方法名#>:(<#AYHandle#>)<#xxHandle#>;
方法block.m 快捷鍵:blockMethod.m
/** 方法block回調(diào) */
@property (nonatomic, copy) <#AYHandle#> <#xxHandle#>;
if (self.<#xxHandle#>) {
self.<#xxHandle#>(<#obj#>);
}
- (void)<#block方法名#>:(<#AYHandle#>)<#xxHandle#> {
self.<#xxHandle#> = <#xxHandle#>;
}
單例 快捷鍵:single
static HLUserManager *_singleton = nil;
@implementation HLUserManager
+ (instancetype)sharedManager {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_singleton = [[HLUserManager alloc] init];
});
return _singleton;
}