2019-05-10 星期五 3

  • 什么是黄金分割
    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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容