宏
#define MethodNotImplemented() \
@throw \
[NSException exceptionWithName:NSInternalInconsistencyException \
reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)] \
userInfo:nil]
.h
@interface DrawMapModelBase : NSObject
#pragma mark 辅助方法
// 子类必须实现
- (BOOL)thisDrawMapModelIsCanBeSeenByTimetag:(NSTimeInterval)time
AndMaxValue:(CGFloat)maxValue
AndMinValue:(CGFloat)minValue;
@end
.m
#import "DrawMapModelBase.h"
@implementation DrawMapModelBase
// 这个model对应的图当前是否可见(子类必须实现)
- (BOOL)thisDrawMapModelIsCanBeSeenByTimetag:(NSTimeInterval)time
AndMaxValue:(CGFloat)maxValue
AndMinValue:(CGFloat)minValue{
MethodNotImplemented();
}
@end
如果子类没有实现这个方法就会崩
网友评论