oc 代码块的使用
#import <UIKit/UIKit.h>
#import "AppDelegate.h"int (^max)(int,int);//定义代码块,类似c的函数指针
typedef void (^SayHello)(); //指定一个类型的代码块;int main(int argc, char * argv[]) {//通过函数闭包的方式实现代码块max=^(int a,int b){return a>b?a:b;};//调用代码块printf("max is %d\n",max(12,13));//定SayHello类型的代码块SayHello sh=^(){printf("Hello oc block\n");};sh();
}
转载于:https://www.cnblogs.com/netcorner/p/4739296.html
总结
- 上一篇: 编码不一致问题-Illegal mix
- 下一篇: crontab 案例