Skip to content

Commit

Permalink
[#142] weak self ์ถ”๊ฐ€
Browse files Browse the repository at this point in the history
  • Loading branch information
meenyweeny committed Jul 29, 2022
1 parent db8b32c commit 82e16f0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ extension CheckMessageViewController: UICollectionViewDelegate {

extension CheckMessageViewController {
private func getMessageInfo() {
CheckMessageAPI.shared.getCheckMessage { response in
guard let responseData = response else { return }
self.setMessageInfo(response: responseData.data?.lastAnswer ?? [])
CheckMessageAPI.shared.getCheckMessage { [weak self] messageData in
guard let messageData = messageData else { return }
self?.setMessageInfo(response: messageData.data?.lastAnswer ?? [])
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ extension CheckTimeTravelViewController: UITableViewDelegate {

extension CheckTimeTravelViewController {
private func getTimeTravelInfo() {
CheckTimeTravelAPI.shared.getCheckTimeTravel { response in
guard let responseData = response else { return }
self.timeTapes = responseData.data?.timeTravels ?? []
self.setTimeTravelTapeInfo()
CheckTimeTravelAPI.shared.getCheckTimeTravel { [weak self] tapeData in
guard let tapeData = tapeData else { return }
self?.timeTapes = tapeData.data?.timeTravels ?? []
self?.setTimeTravelTapeInfo()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ extension CheckTimeTravelDetailViewController: UICollectionViewDelegateFlowLayou
// MARK: - Network

extension CheckTimeTravelDetailViewController {
func getTravelInfo(timeTravelId: String) {
CheckTimeTravelAPI.shared.getTimeTravelDetail(timeTravelId: timeTravelId) { response in
guard let info = response?.data as? CheckTimeTravelDetailResponse else { return }
self.travelInfo = info
self.dialogs = info.messages
self.collectionView.reloadData()
private func getTravelInfo(timeTravelId: String) {
CheckTimeTravelAPI.shared.getTimeTravelDetail(timeTravelId: timeTravelId) { [weak self] travelData in
guard let travelData = travelData?.data as? CheckTimeTravelDetailResponse else { return }
self?.travelInfo = travelData
self?.dialogs = travelData.messages
self?.collectionView.reloadData()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class MainViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
setUI()
setData()
setDate()
setDelegate()
setGesture()
setBackSwipeGesture()
Expand All @@ -54,10 +54,6 @@ final class MainViewController: UIViewController {
setLayout()
}

private func setData() {
setDate()
}

private func setDelegate() {
backgroundScrollView.delegate = self
}
Expand Down Expand Up @@ -144,9 +140,9 @@ extension MainViewController: UIScrollViewDelegate {

extension MainViewController {
private func getMainData() {
MainAPI.shared.getMain { mainData in
MainAPI.shared.getMain { [weak self] mainData in
guard let mainData = mainData else { return }
self.setCountLabel(count: mainData.data?.timeTravelCount ?? 0)
self?.setCountLabel(count: mainData.data?.timeTravelCount ?? 0)
}
}
}
Expand Down

0 comments on commit 82e16f0

Please sign in to comment.