zoukankan      html  css  js  c++  java
  • 自己曾经没注意的东西

    一些曾经自己没注意到的

    1.error handling  :: When methods return an error parameter by reference, check the returned value, not the error variable

    NSError *error = nil;

    if(![self trySomethingWithError:&error]){

    }

    2. 命名:

    constans :: Constants should be camel-case with all words capitalized and prefixed by the related class name for clarity.

       static const NSTimeInterval ZOCSignInViewControllerFadeOutAnimationDuration = 0.4;

    ::Constants exposed externally should use this pattern in the interface file:

    extern NSString *const ZOCCacheControllerDidClearCacheNotification;

    Method:: The usage of the word "and" is reserved. It should not be used for multiple parameters as illustrated
    in the initWithWidth:height: example below.

    literals:: 用最简便的方法初始化,防止没有对象生产,如NSArray


    回顾单例写法
    + (instancetype)sharedInstance{
      static id shareInstance = nil;
      static dispatch_once_t onceToken = 0;
      
      dispatch_once(&onceToken,^{
        sharedInstance = [[self alloc] init];
      });
      return sharedInstance;  
    }



    block::
    __weak __typeof(self) weakSelf = self;
    [self executeBlock:^(NSData *data, NSError *error) {
        [weakSelf doSomethingWithData:data];
    }];

    __weak __typeof(self)weakSelf = self;
    [self executeBlock:^(NSData *data, NSError *error) {
        __strong __typeof(weakSelf) strongSelf = weakSelf;
        if (strongSelf) {
            [strongSelf doSomethingWithData:data];
            [strongSelf doSomethingWithData:data];
        }
    }];
     




  • 相关阅读:
    纯js生成验证码
    按位与,按位或,按位异或,按位取反
    如何使用SVN?
    tp框架-----文件上传
    tp框架---验证码详解
    tp框架为什么验证码加载不出来?----- ob_clean() 可解决
    tp框架-----Model模型层
    PHP错误调试
    对静态页面的一些理解
    wamp环境配置;转自发瑞的博客(www.cnblogs.com/cyrfr/p/6483529.html)
  • 原文地址:https://www.cnblogs.com/Ohero/p/4417141.html
Copyright © 2011-2022 走看看