zoukankan      html  css  js  c++  java
  • objective-c技巧,细节

    1.绝对值函数abs(),可用于求两个数值之间的差距

    2.如果代码如下:

     if (some condition) {

      something = YES;

      } else {

      something = NO;

      } 

    则,可用something = (some condition); 代替

     3.用Properties的好处有两个:

      (1)方便,省代码:the compiler automatically adds the setText and text methods to your object, as well as the instance variable that will hold the     value for this property. Now you can simply use dot syntax to read and write the value of text. 

       (2)符合面向对象的封装性:when you put properties in the @interface to make data available to others,you use properties these other objects never     directly access your internal instance variables, they always go through a getter or setter method first. 

     4.id类型常用的地方:

      You’ll often use id to describe an object that conforms to a specific protocol, without having to know anything about its class. That’s what you’ve been doing for your delegates all along: 

      @property (nonatomic,weak) id <ItemDetailViewControllerDelegate> delegate;

      The notation id <ItemDetailViewControllerDelegate> means: “I only care that this object implements the ItemDetailViewControllerDelegate protocol but its actual class is not important to me.” 

      该delegate指向实现了ItemDetailViewControllerDelegate协议方法的对象(视图控制器),但delegate所在的对象(视图控制器)除了知道那个对象实现了协议方法外,不需要知道任何其他东西

  • 相关阅读:
    Edit Distance编辑距离(NM tag)- sam/bam格式解读进阶
    《开讲啦》 20160910 颜宁:女科学家去哪儿了?
    pysam
    Python项目实战
    最小二乘估计法
    最大似然估计(Maximum Likelihood,ML)
    HMM隐马尔科夫模型
    贝叶斯推断|朴素贝叶斯分类|贝叶斯定理
    解决“tar:Exiting with failure status due to previous errors”【转】
    df -h执行卡住不动问题解决【转】
  • 原文地址:https://www.cnblogs.com/guitarandcode/p/5445890.html
Copyright © 2011-2022 走看看