-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fix] #165 - isEditMode 버튼 토글 및 activityRecordList 초기화 문제 해결 #166
The head ref may contain hidden characters: "fix/#165-\uB0B4-\uB7EC\uB2DD-\uAE30\uB85D-\uC0AD\uC81C-\uBB38\uC81C-\uD574\uACB0"
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,8 @@ extension ActivityRecordInfoVC { | |
|
||
extension ActivityRecordInfoVC { | ||
func wantsToDelete() { | ||
self.deleteRecordList = [Int]() | ||
|
||
print("삭제 실행") | ||
|
||
guard let selectedRecords = activityRecordTableView.indexPathsForSelectedRows else { return } | ||
|
@@ -135,6 +137,7 @@ extension ActivityRecordInfoVC { | |
self.deleteRecordList.append(activityRecordList[indexPath.row].id) | ||
} | ||
|
||
self.isEditMode.toggle() | ||
deleteRecord() | ||
} | ||
} | ||
|
@@ -143,6 +146,7 @@ extension ActivityRecordInfoVC { | |
|
||
extension ActivityRecordInfoVC { | ||
@objc func editButtonDidTap() { | ||
print(isEditMode) | ||
if isEditMode { | ||
self.totalNumOfRecordlabel.text = "총 기록 \(self.activityRecordList.count)개" | ||
self.editButton.setTitle("편집", for: .normal) | ||
|
@@ -168,6 +172,9 @@ extension ActivityRecordInfoVC { | |
self.present(deleteAlertVC, animated: false, completion: nil) | ||
deleteAlertVC.rightButtonTapAction = { [weak self] in | ||
deleteAlertVC.dismiss(animated: false) | ||
let activityRecordInfoVC = ActivityRecordInfoVC() | ||
activityRecordInfoVC.isEditMode = false | ||
return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 171줄 보면 deleteAlertVC에서 버튼 터치 액션을 지정해주고자 delegate도 사용하고 있고 여기에서는 클로저도 사용해서 2중으로 지정해주고 있네요 그리고! 지금처럼 let activityRecordInfoVC = ActivityRecordInfoVC()
activityRecordInfoVC.isEditMode = false 이렇게 하면 아예 새로운 ActivityRecordInfoVC를 만들고 그 뷰의 edit모드를 설정하는 거라 현재 사용자가 보고 있는 ActivityRecordInfoVC에는 아무런 영향이 없을거에요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 클로저 안에서 현재 VC에 접근하려면 그냥 self?.하면 되는 거였군요....... 감사합니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 맞아요! 하지만 이렇게 클로저로 self를 넣을 수 있다는 점으로 인해 발생하는 문제가 바로 retain Cycle이고 ARC와 연관이 있습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아!! 그랫군요 이해햇습니다 !! 그 부분 공부해볼게요!! |
||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.deleteRecordList = selectedRecords.map { activityRecordList[$0].id }
이렇게 for ~ in 대신에 고차함수를 사용해 깔끔하게 작성하는 방법도 있습니다. 성능은 동일해요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
와아!!! 감사합니다