Xcode中OC常用代碼塊

Xcode-Code-Mark Of OC

簡(jiǎn)介

本文列舉了以下代碼塊

  • Mark Section Title
  • Mark ChildNode Of Section
  • Singleton Instance
  • Standardize Structure Of Code (VC)
  • Standardize Structure Of Code (View)
  • Standardize Structure Of Code (Object)

如有問(wèn)題,歡迎到GitHub上提出Issue。

以下開(kāi)始干貨:

Mark Section Title

Title Mark Section Title
Summary 內(nèi)容標(biāo)記
Completion Shortcut Mark Section Title
#pragma mark - <#Section Title #>

Mark ChildNode Of Section

Title Mark ChildNode Of Section
Summary 標(biāo)記章節(jié)的子節(jié)點(diǎn)
Completion Shortcut Mark ChildNode Of Section
#pragma mark └ <#ChildNode#>

Singleton Instance

Title Singleton Instance
Summary 單例
Completion Shortcut Singleton Instance
+ (instancetype)sharedInstance {
    static dispatch_once_t pred;
    __strong static id instance = nil;
    dispatch_once( &pred, ^{
        instance = [[self alloc] init];
    });
    return instance;
}

Standardize Structure Of Code (VC)

Title Standardize Structure Of Code (VC)
Summary VC 代碼結(jié)構(gòu)
Completion Shortcut Structure VC
#pragma mark - LifeCycle 生命周期
#pragma mark └ Dealloc
- (void)dealloc {
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark └ Init
- (instancetype)init {
    if(self = [super init]) {
        
    }
    return self;
}
#pragma mark └ Content View Loading
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupContentViews];
    [self fetchContentData];
    [self setExtentdedLayoutEdgeZero];
}
/**
 *  初始化界面并設(shè)置布局
 */
- (void)setupContentViews {
    [self layoutPageSubViews];
}
/**
 *  設(shè)置布局
 */
- (void)layoutPageSubViews {
}
/**
 *  獲取數(shù)據(jù)并繪制界面
 */
- (void)fetchContentData {
    [self renderContentViews];
}
/**
 *  繪制界面
 */
- (void)renderContentViews {
}
/**
 *  設(shè)置頂部導(dǎo)航欄拓展布局為空
 */
- (void)setExtentdedLayoutEdgeZero {
    if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
}

#pragma mark - Event Response 事件響應(yīng)
#pragma mark - Delegate Realization 委托方法
#pragma mark - Custom Method    自定義方法
#pragma mark └ Other
#pragma mark - Custom Accessors 自定義屬性

Standardize Structure Of Code (View)

Title Standardize Structure Of Code (View)
Summary View 代碼結(jié)構(gòu)
Completion Shortcut Structure View
#pragma mark - + 靜態(tài)方法
+ (instancetype)view {
    id view = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil].firstObject;
    return view;
}
#pragma mark - Overridden Methods
#pragma mark └ Dealloc
- (void)dealloc { }
#pragma mark └ LifeCycle 生命周期
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self commonInit];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self commonInit];
}

- (void)commonInit {
    
}
#pragma mark - Private Method    自定義方法
#pragma mark - Event Response 事件響應(yīng)
#pragma mark - Delegate Realization 委托實(shí)現(xiàn)
#pragma mark - Helper Method 幫助方法
#pragma mark - Custom Accessors 自定義屬性

Standardize Structure Of Code (Object)

Title Standardize Structure Of Code (Object)
Summary Object 代碼結(jié)構(gòu)
Completion Shortcut Structure Object
#pragma mark - LifeCycle 生命周期
#pragma mark └ Dealloc
- (void)dealloc {
}
#pragma mark └ Init
- (instancetype)init {
    if(self = [super init]) {
        
    }
    return self;
}

#pragma mark - Event Response 事件響應(yīng)
#pragma mark - Delegate Realization 委托方法
#pragma mark - Custom Method    自定義方法
#pragma mark └ Other
#pragma mark - Custom Accessors 自定義屬性

持續(xù)更新中...

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容