1.属性用法
^ 后面就是block的名称,必须是copy
#import <UIKit/UIKit.h>
#import <SCCUserInterface/SCCTableViewCellProtocol.h>
#import "CNNOrderButtonView.h"
@interface CNNCarOrderCell : UITableViewCell <SCCTableViewCellProtocol>
+ (CGFloat)cellHeightWithItem:(id)item width:(CGFloat)width;
@property (nonatomic, copy) void (^buttonTappedBlock)(NSInteger index, CNNOrderButtonActionType type);
@end
2.类外面申明,成为一种数据类型
(^CNNCloseLocationBlock) CNNCloseLocationBlock成为新的数据类型,即函数指针
#import <Foundation/Foundation.h>
typedef void (^CNNCloseLocationBlock)(NSDictionary *dict);
@interface CNNCloseCarLocationManager : NSObject
@property (nonatomic,copy) CNNCloseLocationBlock locationBlock;
@property (nonatomic,copy) void(^location)(NSError *error,NSDictionary*geolocation);
+ (instancetype)manager NS_SWIFT_NAME(sharedInstance());
- (void)startUpdatingLocation;
- (void)setGetLocationBlock:(void(^)(NSDictionary * dic))block;
- (void)setGetGeoLocationBlock:(void(^)(NSError *error,NSDictionary*geolocation))block;
@end
3.方法中的参数block用法
(^block xx) block名称从括号中写在外面成为参数
- (void)setGetLocationBlock:(void(^)(NSDictionary * dic))block;
总结: 一般情况(^)后面都会跟block名称,参数除外