diff --git a/Runnect-iOS/Runnect-iOS/Global/UIComponents/RNAlertVC.swift b/Runnect-iOS/Runnect-iOS/Global/UIComponents/RNAlertVC.swift index 292ddc91..61cb6fbd 100644 --- a/Runnect-iOS/Runnect-iOS/Global/UIComponents/RNAlertVC.swift +++ b/Runnect-iOS/Runnect-iOS/Global/UIComponents/RNAlertVC.swift @@ -15,9 +15,7 @@ final class RNAlertVC: UIViewController { // MARK: - Properties var rightButtonTapAction: (() -> Void)? - - var deleteRecordDelegate: deleteRecordDelegate? - + // MARK: - UI Components private let containerView = UIView().then { @@ -98,7 +96,6 @@ extension RNAlertVC { @objc private func touchYesButton() { self.rightButtonTapAction?() - deleteRecordDelegate?.wantsToDelete() } } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/ActivityRecordInfoVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/ActivityRecordInfoVC.swift index 12d8dd04..bc23dce1 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/ActivityRecordInfoVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/InfoVC/ActivityRecordInfoVC.swift @@ -11,11 +11,7 @@ import SnapKit import Then import Moya -protocol deleteRecordDelegate: AnyObject { - func wantsToDelete() -} - -final class ActivityRecordInfoVC: UIViewController, deleteRecordDelegate { +final class ActivityRecordInfoVC: UIViewController { // MARK: - Properties @@ -24,9 +20,7 @@ final class ActivityRecordInfoVC: UIViewController, deleteRecordDelegate { private var activityRecordList = [ActivityRecord]() private var deleteRecordList = [Int]() - - weak var delegate: deleteRecordDelegate? - + private var isEditMode: Bool = false // MARK: - UI Components @@ -127,14 +121,11 @@ extension ActivityRecordInfoVC { extension ActivityRecordInfoVC { func wantsToDelete() { - print("삭제 실행") - - guard let selectedRecords = activityRecordTableView.indexPathsForSelectedRows else { return } + self.deleteRecordList = activityRecordTableView.indexPathsForSelectedRows?.map { activityRecordList[$0.row].id } ?? [] - for indexPath in selectedRecords { - self.deleteRecordList.append(activityRecordList[indexPath.row].id) - } + print("삭제 실행") + self.isEditMode.toggle() deleteRecord() } } @@ -143,6 +134,7 @@ extension ActivityRecordInfoVC { extension ActivityRecordInfoVC { @objc func editButtonDidTap() { + print(isEditMode) if isEditMode { self.totalNumOfRecordlabel.text = "총 기록 \(self.activityRecordList.count)개" self.editButton.setTitle("편집", for: .normal) @@ -164,10 +156,12 @@ extension ActivityRecordInfoVC { @objc func deleteRecordButtonDidTap() { let deleteAlertVC = RNAlertVC(description: "러닝 기록을 정말로 삭제하시겠어요?").setButtonTitle("취소", "삭제하기") deleteAlertVC.modalPresentationStyle = .overFullScreen - deleteAlertVC.deleteRecordDelegate = self self.present(deleteAlertVC, animated: false, completion: nil) deleteAlertVC.rightButtonTapAction = { [weak self] in deleteAlertVC.dismiss(animated: false) + self?.wantsToDelete() + self?.isEditMode = false + return } } }