两种方法:
1.
typedef void (^doBlockAction)();
-(void)doSomething:(doBlockAction)doBlock
{
doBlock();
}
2.
@property (nonatomic,copy) dispatch_block_t doBlockAction;
if (self.doBlockAction)
{
self.doBlockAction();
}
调用:
MyClass *c = [[MyClass alloc]init];
c.doBlockAction = ^() {
NSLog(@"do Something");
};
时间: 2024-10-27 13:58:05