首页 > 代码库 > oc中的block使用心得

oc中的block使用心得

typedef   void (^ simpleBlock) (void);typedef  double (^multiplyTwoValues)(double, double);typedef   void (^ simpleTestBlock) (int ,int);@implementation TJAppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    // Override point for customization after application launch.     simpleBlock block =^{        NSLog(@"this is a block");        };       block();    multiplyTwoValues values=^(double x,double y)    {                return x *y;    };    NSLog(@"%.3f",values(2.0,3.0));    simpleTestBlock  testBlock=^(int x,int y)    {        NSLog(@"--->%d",x+y);    };    testBlock(2,3);        return YES;}

 

oc中的block使用心得