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];
        }
    }];
     




  • 相关阅读:
    处理缺失值
    数据清理
    数据聚合
    ajax动态生成table
    MangeEmpHashMap
    Arraylist的雇员管理操作
    jsp获取一个对象和list对象
    Controller比较两个对象discs、outlets中的元素是否相等。相同则相应的checkbox为checked
    限制input text输入的类型(数字,字母,小数点)
    联合主键的映射运用
  • 原文地址:https://www.cnblogs.com/Ohero/p/4417141.html
Copyright © 2011-2022 走看看