Last active
October 24, 2025 04:28
-
-
Save Awesomeplayer165/ff2b5f3519582711c1f3809e833120c4 to your computer and use it in GitHub Desktop.
jeopardy.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class QuestionsAndAnswers { | |
| let question: String | |
| let answer: String | |
| init(question: String, answer: String) { | |
| self.question = question | |
| self.answer = answer | |
| } | |
| } | |
| let questionsAndAnswers: [(Int, Int): QuestionsAndAnswers] = [ | |
| (0, 0): QuestionsAndAnswers("What are two types of books?"), "What are nonfiction and fiction?"), | |
| (0, 1): QuestionsAndAnswers("What are two types of books?"), "What are nonfiction and fiction?"), | |
| (0, 2): QuestionsAndAnswers("What are two types of books?"), "What are nonfiction and fiction?"), | |
| (0, 3): QuestionsAndAnswers("What are two types of books?"), "What are nonfiction and fiction?"), | |
| (0, 4: QuestionsAndAnswers("What are two types of books?"), "What are nonfiction and fiction?"), | |
| // (0, 5): QuestionsAndAnswers("What are two types of books?"), "What are nonfiction and fiction?") | |
| ] | |
| class Home: UIViewController { | |
| fileprivate weak var tableView = UITableView() | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| tableView.delegate = self | |
| tableView.dataSource = self | |
| } | |
| } | |
| extension Home: UITableViewDelegate, UITableViewDataSource { | |
| func indexForRowAt(indexPath: IndexPath) { | |
| } | |
| func userClicked(indexPath: IndexPath) { | |
| let questionVC = storyboard?.instantiateViewController(with: "Question") as! Question | |
| questionVC.questionsAndAnswer = questionsAndAnswers[(indexPath.column, indexPath.row)] | |
| self.present(questionVC, animated: true) | |
| } | |
| } | |
| class Question: UIViewController { | |
| var questionsAndAnswer: QuestionsAndAnswers | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| question.title = questionsAndAnswers.question | |
| } | |
| @obj func clickedAnswer() { | |
| let vc = modalbox... | |
| vc.title = question.answer | |
| present(vc) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment