修复 Swift 方法重载冲突

问题:
- refreshTabBar(isLogin:) 和 refreshTabBarWithIsLogin(_:)
- 在 OC 中生成相同的 selector 'refreshTabBarWithIsLogin:'
- 导致编译冲突

修复:
- 移除 refreshTabBar(isLogin:) 的 @objc 标记
- 保留 refreshTabBarWithIsLogin(_:) 的 @objc 标记
- 内部调用改为 Swift 方法

这样 OC 只能看到 refreshTabBarWithIsLogin: 方法
Swift 内部可以使用更简洁的 refreshTabBar(isLogin:) 方法
This commit is contained in:
edwinQQQ
2025-10-10 14:22:00 +08:00
parent a684c7e4f7
commit 03e656f209
11 changed files with 66 additions and 66 deletions

View File

@@ -7,14 +7,14 @@
//
#import "EPMomentViewController.h"
#import "NewMomentCell.h"
#import "EPMomentCell.h"
#import <Masonry/Masonry.h>
#import "Api+Moments.h"
#import "AccountInfoStorage.h"
#import "MomentsInfoModel.h"
#import <MJExtension/MJExtension.h>
@interface NewMomentViewController () <UITableViewDelegate, UITableViewDataSource>
@interface EPMomentViewController () <UITableViewDelegate, UITableViewDataSource>
// MARK: - UI Components
@@ -80,7 +80,7 @@
make.size.mas_equalTo(CGSizeMake(56, 56));
}];
NSLog(@"[NewMomentViewController] UI 设置完成");
NSLog(@"[EPMomentViewController] UI 设置完成");
}
// MARK: - Data Loading
@@ -89,7 +89,7 @@
if (self.isLoading) return;
self.isLoading = YES;
NSLog(@"[NewMomentViewController] 开始加载数据,页码: %ld", (long)self.currentPage);
NSLog(@"[EPMomentViewController] 开始加载数据,页码: %ld", (long)self.currentPage);
// API
NSString *page = [NSString stringWithFormat:@"%ld", (long)self.currentPage];
@@ -108,12 +108,12 @@
[self.dataSource addObjectsFromArray:list];
self.currentPage++;
[self.tableView reloadData];
NSLog(@"[NewMomentViewController] 加载成功,新增 %lu 条动态", (unsigned long)list.count);
NSLog(@"[EPMomentViewController] 加载成功,新增 %lu 条动态", (unsigned long)list.count);
} else {
NSLog(@"[NewMomentViewController] 没有更多数据");
NSLog(@"[EPMomentViewController] 没有更多数据");
}
} else {
NSLog(@"[NewMomentViewController] 加载失败: code=%ld, msg=%@", (long)code, msg);
NSLog(@"[EPMomentViewController] 加载失败: code=%ld, msg=%@", (long)code, msg);
// API
if (self.dataSource.count == 0) {
//
@@ -132,7 +132,7 @@
// MARK: - Actions
- (void)onPublishButtonTapped {
NSLog(@"[NewMomentViewController] 发布按钮点击");
NSLog(@"[EPMomentViewController] 发布按钮点击");
// TODO:
[self showAlertWithMessage:@"发布功能开发中"];
}
@@ -152,7 +152,7 @@
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NewMomentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"NewMomentCell" forIndexPath:indexPath];
EPMomentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"NewMomentCell" forIndexPath:indexPath];
if (indexPath.row < self.dataSource.count) {
MomentsInfoModel *model = self.dataSource[indexPath.row];
@@ -167,7 +167,7 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSLog(@"[NewMomentViewController] 点击动态: %ld", (long)indexPath.row);
NSLog(@"[EPMomentViewController] 点击动态: %ld", (long)indexPath.row);
// TODO:
[self showAlertWithMessage:[NSString stringWithFormat:@"点击了第 %ld 条动态", (long)indexPath.row]];
}
@@ -206,7 +206,7 @@
_tableView.contentInset = UIEdgeInsetsMake(10, 0, 10, 0);
// Cell
[_tableView registerClass:[NewMomentCell class] forCellReuseIdentifier:@"NewMomentCell"];
[_tableView registerClass:[EPMomentCell class] forCellReuseIdentifier:@"NewMomentCell"];
//
_tableView.refreshControl = self.refreshControl;