Xcode的代碼片段(Code Snippets)創(chuàng)建自定義的代碼片段

代碼片段

Xcode的代碼片段(Code Snippets)創(chuàng)建自定義的代碼片段,當(dāng)你重用這些代碼片段時(shí),會(huì)給你帶來(lái)很大的方便。

常用代碼塊

1 .@copy觸發(fā)

@property?(nonatomic, copy)?NSString?*<#string#>;

2. @strong

@property?(nonatomic, strong)?<#Class#>?*<#object#>;

3. @weak

@property?(nonatomic, weak)?<#Class#>?*<#object#>;

4. @assign

@property?(nonatomic, assign)?<#Class#>?<#property#>;

5. @delegate

@property?(nonatomic, weak)?id<<#protocol#>>?<#delegate#>;

6. @block

@property?(nonatomic, copy)?<#Block#>?<#block#>;

7. @mark

#pragma?mark -?<#mark#>

8. @warning

#warning?<#message#>

9. @?reuseCell:

static NSString *cellIdentifier=<#rid#>;

<#Class#> *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];

if(cell==nil){

cell = [[<#Class#> alloc] initWithStyle:UITableViewCellStyleDefault? reuseIdentifier:cellIdentifier];

}

return cell;



@mainGCD

dispatch_async(dispatch_get_main_queue(),?^{

<#code#>

});

@globalGCD

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,?0),?^{

<#code#>

});

@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#>

});

@onceTokenGCD

static?dispatch_once_t?onceToken;

dispatch_once(&onceToken,?^{

<#code?to?be?executed?once#>

});

最后編輯于
?著作權(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)容