Xcode常用代码块(不定时更新)

标签: iOS Xcode


最近电脑有问题,经常重装,最痛苦的是Xcode中的代码块和插件都要重新安装,为了方便自己也为了方便他人,我就把常用的代码块贴出来,省的下次还要一个个收集。

人工编辑,难免有错误,还望大家不吝赐教,/手动抱拳
大家如果有好的也可以分享出来,只为提高我们的开发效率。


// 懒加载
-(<#type#>) <#name#> {
    if (!_<#name#>) {
        _<#name#> = <#statements#>
    }
    return _<#name#>;
}
// 屏幕尺寸
#define k_ScreenWidth [UIScreen mainScreen].bounds.size.width
#define k_ScreenHeight [UIScreen mainScreen].bounds.size.height
// UIwindow
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.window setBackgroundColor:[UIColor blackColor]];
    [self.window makeKeyAndVisible];
    [self.window setRootViewController:<#(UIViewController * _Nullable)#>];
// UIWidow + UINavigationcontroller

self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
[self.window setBackgroundColor:[UIColor <#whiteColor#>]];
[self.window makeKeyAndVisible];
self.window.rootViewController = [[UINavigationController alloc]initWithRootViewController:[<#ViewController#> new]];
// strong
/** <#注释#> */
@property (strong, nonatomic) <#class#> * <#name#>;
// assign
/** <#注释#> */
@property (assign, nonatomic) <#type#> <#name#>;
// copy
/** <#注释#> */
@property (copy, nonatomic) <#type#> <#name#>;
// 代理
/** <#注释#> */
@property(weak, nonatomic) id <<#classDelegate#>> <#delegateName#>;

  • 以下更新于2016.08.10
// 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#>];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容