美文网首页
2019-05-10 星期五 3

2019-05-10 星期五 3

作者: 老布威利斯 | 来源:发表于2019-05-10 23:22 被阅读0次
    • 什么是黄金分割
      The golden ratio is a special number approximately equal to 1.618,we find the golden ratio when we divide a line into two parts so that :the whole lenght divided by the long part is also equal to the long part divided by the short part.


      image.png
      image.png

      code:

    void caculateGoldenRatio(){
        static double number = 2;
        number = 1 / number + 1;
        printf("%lf\n",number);
        caculateGoldenRatio();
    }
    

    参考链接:https://www.mathsisfun.com/numbers/golden-ratio.html

    • runtime 调用方法的另一种写法
      原理:拿到imp指针,直接传值调用,等价于 performSeletor
        Class class = NSClassFromString(target);
        SEL selector = NSSelectorFromString(action);
        if ([class respondsToSelector:selector]) {
            void *(*func)(id, SEL) = (void *)[class methodForSelector:selector];
            void *returnValue = func(class,selector);
        }
    
    • 忽略编译器的警告写法
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
    //write the code here
    #pragma clang diagnostic pop
    

    参考链接:https://www.jianshu.com/p/84a934fe6f86

    相关文章

      网友评论

          本文标题:2019-05-10 星期五 3

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