1
This commit is contained in:
@@ -26,11 +26,6 @@
|
||||
return @{@"replies" : [KBAIReplyModel class]};
|
||||
}
|
||||
|
||||
- (void)setLiked:(NSInteger)liked {
|
||||
// 后端返回的是 NSInteger (0/1),转换为 BOOL
|
||||
_isLiked = (liked == 1);
|
||||
}
|
||||
|
||||
- (void)setCreatedAt:(NSString *)createdAt {
|
||||
// 后端返回的是字符串时间,转换为时间戳
|
||||
if (createdAt && createdAt.length > 0) {
|
||||
@@ -44,6 +39,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - MJExtension Hook
|
||||
|
||||
/// MJExtension 转换完成后的钩子方法,用于处理空值
|
||||
- (void)mj_didConvertToObjectWithKeyValues:(NSDictionary *)keyValues {
|
||||
// 防止后端返回 null,统一设置空字符串为默认值
|
||||
if (!_commentId) {
|
||||
_commentId = @"";
|
||||
}
|
||||
if (!_userId) {
|
||||
_userId = @"";
|
||||
}
|
||||
if (!_userName) {
|
||||
_userName = @"";
|
||||
}
|
||||
if (!_avatarUrl) {
|
||||
_avatarUrl = @"";
|
||||
}
|
||||
if (!_content) {
|
||||
_content = @"";
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
@@ -133,7 +150,8 @@
|
||||
|
||||
// 内容高度(多行)
|
||||
UIFont *contentFont = [UIFont systemFontOfSize:15];
|
||||
CGRect contentRect = [self.content boundingRectWithSize:CGSizeMake(contentWidth, CGFLOAT_MAX)
|
||||
NSString *contentText = self.content ?: @"";
|
||||
CGRect contentRect = [contentText boundingRectWithSize:CGSizeMake(contentWidth, CGFLOAT_MAX)
|
||||
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
|
||||
attributes:@{NSFontAttributeName: contentFont}
|
||||
context:nil];
|
||||
|
||||
Reference in New Issue
Block a user