oc 代码块的使用
#import <UIKit/UIKit.h>
#import "AppDelegate.h"int (^max)(int,int);//定義代碼塊,類似c的函數(shù)指針
typedef void (^SayHello)(); //指定一個類型的代碼塊;int main(int argc, char * argv[]) {//通過函數(shù)閉包的方式實現(xiàn)代碼塊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 案例