不是很明白 @property (nonatomic, copy) void(^doTransferMsg)(NSString *_msg)
这种声明属性方式。只知道void(^doTransferMsg)这是使用block方式声明方法。
光阴似箭催人老,日月如移越少年。
Maybe it’s easier to understand this way .h
typedef void(^doTransferMsg)(NSString *_msg); @property (nonatomic, copy) doTransferMsg transferMsg;
.m
@synthesize transferMsg; [self setTransferMsg:^(NSString *str) { NSLog(@"hello %@",str); }]; transferMsg(@"navy"); transferMsg(@"navy2");
You will understand if you think of block as a common type. There is no difference between block and common types here. They just define an attribute of this type.
Maybe it’s easier to understand this way
.h
.m
You will understand if you think of block as a common type. There is no difference between block and common types here. They just define an attribute of this type.