Skip to content

Commit 075a33d

Browse files
committed
m
1 parent 5037d28 commit 075a33d

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

JHCellConfigDemo/BaseClass/JHBaseCell.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515

1616
@interface JHBaseCell : UITableViewCell <JHCellConfigProtocol>
1717

18+
@property (nonatomic, strong) JHCellConfig *cellConfig;
19+
1820
@end

JHCellConfigDemo/BaseClass/JHBaseCell.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
@implementation JHBaseCell
1414

15-
@synthesize cellConfig;
16-
1715
- (void)awakeFromNib {
1816
[super awakeFromNib];
1917
// Initialization code
@@ -35,4 +33,5 @@ - (void)updateContentWithCellConfig:(JHCellConfig *)cellConfig
3533
}
3634

3735

36+
3837
@end

src/JHCellConfig/JHCellConfig.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ typedef void(^JHCellSelectBlock)(JHCellConfig *selectCellConfig, UITableViewCell
1414

1515
@protocol JHCellConfigProtocol <NSObject>
1616

17-
@property (nonatomic, strong) JHCellConfig *cellConfig;
18-
19-
- (void)updateContentWithCellConfig:(JHCellConfig *)cellConfig;
20-
2117
@optional
18+
- (void)updateContentWithCellConfig:(JHCellConfig *)cellConfig;
2219
+ (CGFloat)cellHeightWithCellConfig:(JHCellConfig *)cellConfig;
20+
- (void)setCellConfig:(JHCellConfig *)cellConfig;
2321

2422
@end
2523

src/JHCellConfig/JHCellConfig.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ - (UITableViewCell *)cellOfCellConfigWithTableView:(UITableView *)tableView
6868
}
6969
}
7070

71+
// bind
72+
if ([cell conformsToProtocol:@protocol(JHCellConfigProtocol)]) {
73+
[((id <JHCellConfigProtocol>)cell) setCellConfig:self];
74+
}
75+
7176
// 更新cell界面
7277
if (self.updateContentMethod && [cell respondsToSelector:self.updateContentMethod]) {
7378

@@ -77,9 +82,7 @@ - (UITableViewCell *)cellOfCellConfigWithTableView:(UITableView *)tableView
7782
#pragma clang diagnostic pop
7883
}
7984

80-
if ([cell conformsToProtocol:@protocol(JHCellConfigProtocol)]) {
81-
((id <JHCellConfigProtocol>)cell).cellConfig = self;
82-
}
85+
8386
return cell;
8487
}
8588

0 commit comments

Comments
 (0)