修复 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

@@ -1,5 +1,5 @@
//
// NewMineViewController.h
// EPMineViewController.h
// YuMi
//
// Created by AI on 2025-10-09.

View File

@@ -1,5 +1,5 @@
//
// NewMineViewController.m
// EPMineViewController.m
// YuMi
//
// Created by AI on 2025-10-09.
@@ -7,7 +7,7 @@
//
#import "EPMineViewController.h"
#import "NewMineHeaderView.h"
#import "EPMineHeaderView.h"
#import <Masonry/Masonry.h>
#import "Api+Mine.h"
#import "AccountInfoStorage.h"
@@ -16,7 +16,7 @@
#import <MJExtension/MJExtension.h>
#import "XPSkillCardPlayerManager.h"
@interface NewMineViewController () <UITableViewDelegate, UITableViewDataSource>
@interface EPMineViewController () <UITableViewDelegate, UITableViewDataSource>
// MARK: - UI Components
@@ -24,7 +24,7 @@
@property (nonatomic, strong) UITableView *tableView;
///
@property (nonatomic, strong) NewMineHeaderView *headerView;
@property (nonatomic, strong) EPMineHeaderView *headerView;
///
@property (nonatomic, strong) UIButton *settingsButton;
@@ -56,7 +56,7 @@
[self setupUI];
[self loadData];
NSLog(@"[NewMineViewController] 页面加载完成");
NSLog(@"[EPMineViewController] 页面加载完成");
}
- (void)viewWillAppear:(BOOL)animated {
@@ -89,7 +89,7 @@
//
self.tableView.tableHeaderView = self.headerView;
NSLog(@"[NewMineViewController] UI 设置完成");
NSLog(@"[EPMineViewController] UI 设置完成");
}
// MARK: - Data Loading
@@ -113,7 +113,7 @@
- (void)refreshUserInfo {
NSString *uid = [[AccountInfoStorage instance] getUid];
if (!uid.length) {
NSLog(@"[NewMineViewController] 未登录,无法获取用户信息");
NSLog(@"[EPMineViewController] 未登录,无法获取用户信息");
return;
}
@@ -134,9 +134,9 @@
};
[self.headerView configureWithUserInfo:userInfoDict];
NSLog(@"[NewMineViewController] 用户信息加载成功: %@", self.userInfo.nick);
NSLog(@"[EPMineViewController] 用户信息加载成功: %@", self.userInfo.nick);
} else {
NSLog(@"[NewMineViewController] 用户信息加载失败: %@", msg);
NSLog(@"[EPMineViewController] 用户信息加载失败: %@", msg);
}
} uid:uid];
@@ -156,18 +156,18 @@
// [Api getUserWalletInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
// if (code == 200 && data.data) {
// self.walletInfo = [WalletInfoModel mj_objectWithKeyValues:data.data];
// NSLog(@"[NewMineViewController] 钱包信息加载成功: 钻石=%ld 金币=%ld",
// NSLog(@"[EPMineViewController] 钱包信息加载成功: 钻石=%ld 金币=%ld",
// (long)self.walletInfo.diamond, (long)self.walletInfo.money);
// }
// } fail:^(NSInteger code, NSString * _Nullable msg) {
// NSLog(@"[NewMineViewController] 钱包信息加载失败: %@", msg);
// NSLog(@"[EPMineViewController] 钱包信息加载失败: %@", msg);
// } uid:uid ticket:ticket];
}
// MARK: - Actions
- (void)onSettingsButtonTapped {
NSLog(@"[NewMineViewController] 设置按钮点击");
NSLog(@"[EPMineViewController] 设置按钮点击");
// TODO:
[self showAlertWithMessage:@"设置功能开发中"];
}
@@ -176,7 +176,7 @@
NSString *type = item[@"type"];
NSString *title = item[@"title"];
NSLog(@"[NewMineViewController] 菜单项点击: %@", type);
NSLog(@"[EPMineViewController] 菜单项点击: %@", type);
if ([type isEqualToString:@"wallet"]) {
// TODO:
@@ -274,9 +274,9 @@
return _tableView;
}
- (NewMineHeaderView *)headerView {
- (EPMineHeaderView *)headerView {
if (!_headerView) {
_headerView = [[NewMineHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 280)];
_headerView = [[EPMineHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 280)];
}
return _headerView;
}

View File

@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
/// 新的个人中心头部视图
/// 纵向卡片式设计 + 渐变背景
@interface NewMineHeaderView : UIView
@interface EPMineHeaderView : UIView
/// 配置用户信息
/// @param userInfo 用户信息字典

View File

@@ -6,10 +6,10 @@
// Copyright © 2025 YuMi. All rights reserved.
//
#import "NewMineHeaderView.h"
#import "EPMineHeaderView.h"
#import <Masonry/Masonry.h>
@interface NewMineHeaderView ()
@interface EPMineHeaderView ()
// MARK: - UI Components
@@ -45,7 +45,7 @@
@end
@implementation NewMineHeaderView
@implementation EPMineHeaderView
// MARK: - Lifecycle

View File

@@ -1,5 +1,5 @@
//
// NewMomentViewController.h
// EPMomentViewController.h
// YuMi
//
// Created by AI on 2025-10-09.

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;

View File

@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
/// 新的动态 Cell卡片式设计
/// 完全不同于原 XPMomentsCell 的列表式设计
@interface NewMomentCell : UITableViewCell
@interface EPMomentCell : UITableViewCell
/// 配置 Cell 数据
/// @param model 动态数据模型

View File

@@ -6,13 +6,13 @@
// Copyright © 2025 YuMi. All rights reserved.
//
#import "NewMomentCell.h"
#import "EPMomentCell.h"
#import "MomentsInfoModel.h"
#import "AccountInfoStorage.h"
#import "Api+Moments.h"
#import <Masonry/Masonry.h>
@interface NewMomentCell ()
@interface EPMomentCell ()
// MARK: - UI Components
@@ -51,7 +51,7 @@
@end
@implementation NewMomentCell
@implementation EPMomentCell
// MARK: - Lifecycle

View File

@@ -258,7 +258,7 @@ import UIKit
/// TabBar
/// - Parameter isLogin:
@objc func refreshTabBar(isLogin: Bool) {
func refreshTabBar(isLogin: Bool) {
isLoggedIn = isLogin
if isLogin {