Skip to content

Instantly share code, notes, and snippets.

@Awesomeplayer165
Last active October 24, 2025 04:28
Show Gist options
  • Select an option

  • Save Awesomeplayer165/ff2b5f3519582711c1f3809e833120c4 to your computer and use it in GitHub Desktop.

Select an option

Save Awesomeplayer165/ff2b5f3519582711c1f3809e833120c4 to your computer and use it in GitHub Desktop.
jeopardy.swift
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