// - 宏定义
#define MASMethodNotImplemented() \
@throw [NSException exceptionWithName:NSInternalInconsistencyException \
reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \
userInfo:nil]
// - 父类的声明和实现
@interface MASConstraint : NSObject
- (void)setOffset:(CGFloat)offset;
@end
@implementation MASConstraint
- (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); }
@end
// - 子类的声明和实现
@interface MASViewConstraint : MASConstraint <NSCopying>
@end
@implementation MASViewConstraint
- (void)setOffset:(CGFloat)offset {
self.layoutConstant = offset;
}
@end
masonry源码心得 构建抽象类
最新推荐文章于 2021-07-14 17:28:11 发布