美文网首页
Xcode常用代码块(不定时更新)

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

作者: Ghostlord | 来源:发表于2016-08-04 14:50 被阅读146次

    标签: 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#>];
    

    相关文章

      网友评论

          本文标题: Xcode常用代码块(不定时更新)

          本文链接:https://www.haomeiwen.com/subject/psicsttx.html