Skip to content

Commit

Permalink
fix: Model refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoe0929 committed Jun 4, 2024
1 parent 90a256e commit 66e6208
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ final class AnswerTableViewCell: UITableViewCell {


extension AnswerTableViewCell {
func dataBind(_ data: Question) {
func dataBind(_ data: SimpleQuestion) {
word = data.question
answer = data.answer[1]
wordLabel.text = "\(self.word)의 뜻은"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import SnapKit
import Then

final class AnswerViewController: UIViewController {
let questions: [Question] = [
Question(question: "모집인원 0명의 뜻은", answer: ["0명", "1~6명"]),
Question(question: "명일의 뜻은", answer: ["그저께", "어제", "오늘", "내일"]),
Question(question: "사료하다의 뜻은", answer: ["깊이 생각하여 헤아리다.", "사물을 헤아리고 판단하다", "짜거나 엮은 것이 거칠고 성기다", "여럿 가운데서 하나를 구별하여 고르다"]),
Question(question: "심심한 사과의 뜻은", answer: ["지루한 마음으로 하는 사과", "진심을 다해 간절한 마음으로 하는 사과", "맛이 좋지 않은 사과", "크기가 작은 과일 사과"]),
Question(question: "바야흐로의 뜻은", answer: ["이제 한창", "최고의 경지에 달한 시기"])
let questions: [SimpleQuestion] = [
SimpleQuestion(question: "모집인원 0명의 뜻은", answer: ["0명", "1~6명"]),
SimpleQuestion(question: "명일의 뜻은", answer: ["그저께", "어제", "오늘", "내일"]),
SimpleQuestion(question: "사료하다의 뜻은", answer: ["깊이 생각하여 헤아리다.", "사물을 헤아리고 판단하다", "짜거나 엮은 것이 거칠고 성기다", "여럿 가운데서 하나를 구별하여 고르다"]),
SimpleQuestion(question: "심심한 사과의 뜻은", answer: ["지루한 마음으로 하는 사과", "진심을 다해 간절한 마음으로 하는 사과", "맛이 좋지 않은 사과", "크기가 작은 과일 사과"]),
SimpleQuestion(question: "바야흐로의 뜻은", answer: ["이제 한창", "최고의 경지에 달한 시기"])
]


Expand Down Expand Up @@ -88,7 +88,7 @@ extension AnswerViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: AnswerTableViewCell.identifier, for: indexPath) as? AnswerTableViewCell else { return UITableViewCell() }

cell.dataBind(questions[indexPath.row])
// cell.dataBind(SimpleQuestion[indexPath.row])

if indexPath.row == 1 || indexPath.row == 2 || indexPath.row == 4 {
cell.answerLabel.textColor = UIColor.doRed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import UIKit

import Moya
import SnapKit
import Then

struct Question {
struct SimpleQuestion {
let question: String
let answer: [String]
}

final class QuestionViewController: UIViewController {

let questions: [Question] = [
Question(question: "모집인원 0명의 뜻은", answer: ["0명", "1~6명"]),
Question(question: "명일의 뜻은", answer: ["그저께", "어제", "오늘", "내일"]),
Question(question: "사료하다의 뜻은", answer: ["깊이 생각하여 헤아리다.", "사물을 헤아리고 판단하다", "짜거나 엮은 것이 거칠고 성기다", "여럿 가운데서 하나를 구별하여 고르다"]),
Question(question: "심심한 사과의 뜻은", answer: ["지루한 마음으로 하는 사과", "진심을 다해 간절한 마음으로 하는 사과", "맛이 좋지 않은 사과", "크기가 작은 과일 사과"]),
Question(question: "바야흐로의 뜻은", answer: ["이제 한창", "최고의 경지에 달한 시기"])
let questions: [SimpleQuestion] = [
SimpleQuestion(question: "모집인원 0명의 뜻은", answer: ["0명", "1~6명"]),
SimpleQuestion(question: "명일의 뜻은", answer: ["그저께", "어제", "오늘", "내일"]),
SimpleQuestion(question: "사료하다의 뜻은", answer: ["깊이 생각하여 헤아리다.", "사물을 헤아리고 판단하다", "짜거나 엮은 것이 거칠고 성기다", "여럿 가운데서 하나를 구별하여 고르다"]),
SimpleQuestion(question: "심심한 사과의 뜻은", answer: ["지루한 마음으로 하는 사과", "진심을 다해 간절한 마음으로 하는 사과", "맛이 좋지 않은 사과", "크기가 작은 과일 사과"]),
SimpleQuestion(question: "바야흐로의 뜻은", answer: ["이제 한창", "최고의 경지에 달한 시기"])
]

var index = 0
Expand Down Expand Up @@ -282,7 +284,8 @@ final class QuestionViewController: UIViewController {
}
}

@objc func nextButtonTapped() {
@objc
func nextButtonTapped() {
if index < 4 {
index += 1
setStyle()
Expand Down

0 comments on commit 66e6208

Please sign in to comment.