Skip to content

Commit

Permalink
[Feat] #33 열거형 선언하여 섹션 상수를 열거형 케이스로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
heydoy committed Oct 22, 2022
1 parent b7a6b1e commit e6c6b21
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions SMSH-Summer/SMSH-Summer/Presentation/WriteView/VC/writeVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

import UIKit

enum WriteSection: Int, CaseIterable {
case place = 0
case typekind
case content
}

class writeVC: UIViewController {

// MARK: - UI Components
Expand Down Expand Up @@ -81,7 +87,7 @@ extension writeVC: UITableViewDelegate {
extension writeVC: UITableViewDataSource {

func numberOfSections(in tableView: UITableView) -> Int {
return 3
return WriteSection.allCases.count
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
Expand All @@ -90,13 +96,13 @@ extension writeVC: UITableViewDataSource {

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.section {
case 0:
case WriteSection.place.rawValue:
guard let cell = tableView.dequeueReusableCell(withIdentifier: placeTVC.identifier, for: indexPath) as? placeTVC else { return UITableViewCell() }
return cell
case 1:
case WriteSection.typekind.rawValue:
guard let cell = tableView.dequeueReusableCell(withIdentifier: typeTVC.identifier, for: indexPath) as? typeTVC else { return UITableViewCell() }
return cell
case 2:
case WriteSection.content.rawValue:
guard let cell = tableView.dequeueReusableCell(withIdentifier: contentTVC.identifier, for: indexPath) as? contentTVC else { return UITableViewCell() }
return cell
default:
Expand All @@ -108,11 +114,11 @@ extension writeVC: UITableViewDataSource {
let width = UIScreen.main.bounds.size.width

switch indexPath.section {
case 0:
case WriteSection.place.rawValue:
return width * 0.344
case 1:
case WriteSection.typekind.rawValue:
return width * 0.38
case 2:
case WriteSection.content.rawValue:
return 500
default:
return 200
Expand Down

0 comments on commit e6c6b21

Please sign in to comment.