不是很明白
@property (nonatomic, copy) void(^doTransferMsg)(NSString *_msg)
这种声明属性方式。只知道void(^doTransferMsg)这是使用block方式声明方法。
天蓬老师2017-04-21 11:17:54
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");
PHP中文网2017-04-21 11:17:54
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.