-
什么是黄金分割
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
网友评论