我在一個名爲SIAlertView的開源庫中遇到了一些代碼,我不確定它在做什麼?特別是下面的兩行?什麼是SIAleartViewHandler,因爲它不是SIAlertView庫中的類?這是一個Objective-C塊嗎?
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
@interface SIAlertItem:NSObject是在另一個類.m文件中定義的嗎? – jdog
這是一個類,就像任何其他類一樣,但只能從這個文件內部訪問(因爲沒有公共存在的定義)。 – Wain