我在一个名为 SIAlertView 的开源库中遇到了一些代码,但我不确定它在做什么?特别是下面的两行?什么是 SIAleartViewHandler,因为它不是 SIAlertView 库中的类?
typedef void(^SIAlertViewHandler)(SIAlertView *alertView);
@property (nonatomic, copy) SIAlertViewHandler willShowHandler;
SIAlertView.h
typedef void(^SIAlertViewHandler)(SIAlertView *alertView);
@property (nonatomic, copy) SIAlertViewHandler willShowHandler;
@property (nonatomic, copy) SIAlertViewHandler didShowHandler;
@property (nonatomic, copy) SIAlertViewHandler willDismissHandler;
@property (nonatomic, copy) SIAlertViewHandler didDismissHandler;
SIAlertView.m
[self transitionInCompletion:^{
if (self.didShowHandler) {
self.didShowHandler(self);
}
[[NSNotificationCenter defaultCenter] postNotificationName:SIAlertViewDidShowNotification object:self userInfo:nil];
[SIAlertView setAnimating:NO];
NSInteger index = [[SIAlertView sharedQueue] indexOfObject:self];
if (index < [SIAlertView sharedQueue].count - 1) {
[self dismissAnimated:YES cleanup:NO]; // dismiss to show next alert view
}
}];
#pragma mark - SIAlertItem
@interface SIAlertItem : NSObject
@property (nonatomic, copy) NSString *title;
@property (nonatomic, assign) SIAlertViewButtonType type;
@property (nonatomic, copy) SIAlertViewHandler action;
@end
@implementation SIAlertItem
@end