{"id":4128,"date":"2024-12-08T08:41:25","date_gmt":"2024-12-07T23:41:25","guid":{"rendered":"https:\/\/www.elehobby.fun\/?p=4128"},"modified":"2024-12-08T08:42:52","modified_gmt":"2024-12-07T23:42:52","slug":"chatgpt%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%80%811%e6%99%82%e9%96%93%e3%81%a7iphone%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f%ef%bc%88swiftui%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.elehobby.fun\/?p=4128","title":{"rendered":"ChatGPT\u3092\u4f7f\u7528\u3057\u30011\u6642\u9593\u3067iPhone\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u307f\u305f\uff08swiftUI\uff09"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>2024\u5e746\u670810\u65e5 12:33<\/p>\n\n\n\n<p id=\"07247b27-e709-437c-9baf-a0b4452b116a\">\u4eca\u56de\u306fChatGPT\u3067iPhone\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059\uff01<br>\u7d50\u69cb\u524d\u306bstory bored\u3092\u4f7f\u7528\u3057\u3001\u5c11\u3057\u3060\u3051\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u307f\u305f\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u304c\u3001swiftUI\u306f\u4f7f\u7528\u3057\u305f\u3053\u3068\u304c\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u3068\u308a\u3042\u3048\u305aVStack\u3068\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u9077\u79fb\u306e\u4ed5\u65b9\u3092\u52c9\u5f37\u3057\u3066\u3001\u65e9\u901fChatGPT\u3067\u30b3\u30fc\u30c6\u30a3\u30f3\u30b0\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\uff01<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"0ea776fd-bf56-40ab-8773-1584ecbb5e67\">\u30d7\u30ed\u30f3\u30d7\u30c8<\/h3>\n\n\n\n<p id=\"17c158d5-a90b-4794-b73a-d245cf3a6f66\">\u30af\u30a4\u30ba\u753b\u9762\u3092\u8868\u793a\u3057\u305f\u3044<br>\u30af\u30a4\u30ba\u554f\u984c\u306fCSV\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3001\u30af\u30a4\u30ba\u3092\u8868\u793a\u3059\u308b<br>\u30af\u30a4\u30ba\u306e\u5185\u5bb9\u306f\u82f1\u5358\u8a9e\u3092\u7b54\u3048\u308b\u30af\u30a4\u30ba\u3068\u3059\u308b<br>\u30af\u30a4\u30ba\u306f4\u629e\u3068\u3059\u308b<br>\u554f\u984c\u6570\u306f10\u554f\u3068\u3059\u308b<br>CSV\u30d5\u30a1\u30a4\u30eb\u306e\u554f\u984c\u306f\u30b5\u30f3\u30d7\u30eb\u306e\u554f\u984c\u3092\u3044\u304f\u3064\u304b\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"543f8f54-8599-4a21-b8a6-78c3fa7478b0\">ChatGPT\u306e\u56de\u7b54<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"428395a0-9552-43db-b801-697462d8cf32\">\u307e\u305a\u3001\u30af\u30a4\u30ba\u306e\u554f\u984c\u3092\u542b\u3080CSV\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u3001\u5404\u884c\u306b\u554f\u984c\u3001\u6b63\u89e3\u3001\u9078\u629e\u80a21\u3001\u9078\u629e\u80a22\u3001\u9078\u629e\u80a23\u3001\u9078\u629e\u80a24\u3092\u542b\u3080\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u30b5\u30f3\u30d7\u30eb\u306eCSV\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u793a\u3057\u307e\u3059\u3002<br><br><strong>\u30b5\u30f3\u30d7\u30ebCSV\u30d5\u30a1\u30a4\u30eb (quiz_questions.csv)<\/strong><\/p>\n<\/blockquote>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">question,correct,option1,option2,option3,option4\nWhat is the English word for \"\u72ac\"?,dog,cat,mouse,bird\nWhat is the English word for \"\u732b\"?,cat,dog,mouse,bird\nWhat is the English word for \"\u9ce5\"?,bird,cat,mouse,dog\nWhat is the English word for \"\u30cd\u30ba\u30df\"?,mouse,cat,bird,dog\nWhat is the English word for \"\u99ac\"?,horse,cow,sheep,goat\nWhat is the English word for \"\u725b\"?,cow,horse,sheep,goat\nWhat is the English word for \"\u7f8a\"?,sheep,horse,cow,goat\nWhat is the English word for \"\u5c71\u7f8a\"?,goat,horse,cow,sheep\nWhat is the English word for \"\u30e9\u30a4\u30aa\u30f3\"?,lion,tiger,leopard,cheetah\nWhat is the English word for \"\u30c8\u30e9\"?,tiger,lion,leopard,cheetah<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"91cfbfdf-0c24-4ab6-86d8-0565df1ecd46\">\u6b21\u306b\u3001SwiftUI\u3092\u4f7f\u7528\u3057\u3066\u3053\u306eCSV\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u3001\u30af\u30a4\u30ba\u753b\u9762\u3092\u8868\u793a\u3059\u308b\u30b3\u30fc\u30c9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br><br><strong>CSV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u3068\u30af\u30a4\u30ba\u8868\u793a\u306e\u30b3\u30fc\u30c9<\/strong><\/p>\n<\/blockquote>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import SwiftUI\nimport Foundation\n\nstruct QuizQuestion: Identifiable {\n    let id = UUID()\n    let question: String\n    let correct: String\n    let options: [String]\n}\n\nclass QuizViewModel: ObservableObject {\n    @Published var questions: [QuizQuestion] = []\n    @Published var currentQuestionIndex = 0\n    @Published var score = 0\n    \n    init() {\n        loadCSV()\n    }\n    \n    func loadCSV() {\n        guard let path = Bundle.main.path(forResource: \"quiz_questions\", ofType: \"csv\") else {\n            print(\"CSV file not found\")\n            return\n        }\n        \n        do {\n            let data = try String(contentsOfFile: path)\n            let rows = data.components(separatedBy: \"\\n\")\n            for row in rows.dropFirst() {\n                let columns = row.components(separatedBy: \",\")\n                if columns.count == 6 {\n                    let question = columns[0]\n                    let correct = columns[1]\n                    let options = Array(columns[2...5])\n                    let quizQuestion = QuizQuestion(question: question, correct: correct, options: options.shuffled())\n                    questions.append(quizQuestion)\n                }\n            }\n            questions.shuffle()\n        } catch {\n            print(\"Error reading CSV file: \\(error)\")\n        }\n    }\n    \n    func answerQuestion(with answer: String) {\n        if questions[currentQuestionIndex].correct == answer {\n            score += 1\n        }\n        currentQuestionIndex += 1\n    }\n    \n    func restartQuiz() {\n        score = 0\n        currentQuestionIndex = 0\n        questions.shuffle()\n    }\n}\n\nstruct QuizView: View {\n    @ObservedObject var viewModel = QuizViewModel()\n    \n    var body: some View {\n        NavigationView {\n            VStack {\n                if viewModel.currentQuestionIndex &lt; viewModel.questions.count {\n                    let question = viewModel.questions[viewModel.currentQuestionIndex]\n                    Text(question.question)\n                        .font(.title)\n                        .padding()\n                    ForEach(question.options, id: \\.self) { option in\n                        Button(action: {\n                            viewModel.answerQuestion(with: option)\n                        }) {\n                            Text(option)\n                                .frame(maxWidth: .infinity)\n                                .padding()\n                                .background(Color.blue)\n                                .foregroundColor(.white)\n                                .cornerRadius(10)\n                        }\n                        .padding(.horizontal)\n                    }\n                } else {\n                    Text(\"Quiz Completed!\")\n                        .font(.largeTitle)\n                        .padding()\n                    Text(\"Your score: \\(viewModel.score)\/\\(viewModel.questions.count)\")\n                        .font(.title)\n                        .padding()\n                    Button(action: {\n                        viewModel.restartQuiz()\n                    }) {\n                        Text(\"Restart Quiz\")\n                            .padding()\n                            .background(Color.green)\n                            .foregroundColor(.white)\n                            .cornerRadius(10)\n                    }\n                }\n            }\n            .navigationTitle(\"Quiz\")\n            .padding()\n        }\n    }\n}\n\nstruct ContentView: View {\n    var body: some View {\n        NavigationView {\n            VStack {\n                NavigationLink(destination: QuizView()) {\n                    Text(\"Start Quiz\")\n                        .foregroundColor(.white)\n                        .frame(width: UIScreen.main.bounds.width * 0.9)\n                        .padding()\n                        .background(Color.blue)\n                        .cornerRadius(10)\n                }\n                .padding()\n            }\n            .navigationTitle(\"Main View\")\n        }\n    }\n}\n\nstruct ContentView_Previews: PreviewProvider {\n    static var previews: some View {\n        ContentView()\n    }\n}\n<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"d3d09b8d-84d8-4524-b88b-06ea44d338ae\">\u52d5\u4f5c\u78ba\u8a8d<\/h3>\n\n\n\n<p id=\"fda70fb2-bb9c-44e2-9b5d-2a5c9e336c79\">\u591a\u5c11\u30d0\u30b0\u3082\u3042\u308a\u307e\u3057\u305f\u304c\u30011\u6642\u9593\u7a0b\u5ea6\u3067\u753b\u9762\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\uff01<br>\uff08csv\u306e\u30ab\u30e9\u30e0\u6570\u306f5\u500b\u3060\u304c\u30016\u500b\u306e\u30ed\u30b8\u30c3\u30af\u3068\u306a\u3063\u3066\u3044\u305f\u308a\u3002\u3002\uff09<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">                if columns.count == 6 { \/\/ \u30ed\u30b8\u30c3\u30af\u4e0d\u5099\u3002CSV\u306e\u30ab\u30e9\u30e0\u6570\u306f5\u500b\n                    let question = columns[0]\n                    let correct = columns[1]\n                    let options = Array(columns[2...5]) \/\/ \u30ed\u30b8\u30c3\u30af\u4e0d\u5099\u3002\n                    let quizQuestion = QuizQuestion(question: question, correct: correct, options: options.shuffled())\n                    questions.append(quizQuestion)\n                }<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"c9153c52-63fd-440c-83bd-834fa5b05a0a\"><a href=\"https:\/\/assets.st-note.com\/img\/1717987243715-YOALcy1LBP.png?width=2000&amp;height=2000&amp;fit=bounds&amp;quality=85\"><img decoding=\"async\" src=\"https:\/\/assets.st-note.com\/img\/1717987243715-YOALcy1LBP.png?width=1200\" alt=\"\u753b\u50cf\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\" id=\"d9ee0df4-568a-4749-987c-9b601df7d45b\"><a href=\"https:\/\/assets.st-note.com\/img\/1717987268917-uq9GjlHbwV.png?width=2000&amp;height=2000&amp;fit=bounds&amp;quality=85\"><img decoding=\"async\" src=\"https:\/\/assets.st-note.com\/img\/1717987268917-uq9GjlHbwV.png?width=1200\" alt=\"\u753b\u50cf\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\" id=\"0b58d8e2-7625-4de7-8622-394c0280d8db\"><a href=\"https:\/\/assets.st-note.com\/img\/1717987291849-ROgcoswhDP.png?width=2000&amp;height=2000&amp;fit=bounds&amp;quality=85\"><img decoding=\"async\" src=\"https:\/\/assets.st-note.com\/img\/1717987291849-ROgcoswhDP.png?width=1200\" alt=\"\u753b\u50cf\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"07c86d59-5d04-419e-8f34-6f5eefcd8870\">ChatGPT\u306b\u30b3\u30fc\u30c9\u306e\u5185\u5bb9\u3092\u6559\u3048\u3066\u3082\u3089\u3046<\/h2>\n\n\n\n<p id=\"ce1e66da-678c-4b4c-8f0d-2ca543f03769\">\u7121\u4e8b\u753b\u9762\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u306e\u3067\u3001\u6b21\u306b\u30ed\u30b8\u30c3\u30af\u306e\u5404\u30b9\u30c6\u30c3\u30d7\u306b\u3064\u3044\u3066ChatGPT\u306b\u6559\u3048\u3066\u3082\u3089\u304a\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"add18189-bc39-4795-880a-c064574ceae8\">\u8cea\u554f\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3059\u308b\u69cb\u9020\u4f53<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">struct QuizQuestion: Identifiable {\n    let id = UUID() \/\/ \u4e00\u610f\u306eID\u3092\u751f\u6210\n    let question: String \/\/ \u30af\u30a4\u30ba\u306e\u8cea\u554f\n    let correct: String \/\/ \u6b63\u3057\u3044\u7b54\u3048\n    let options: [String] \/\/ \u9078\u629e\u80a2\u306e\u30ea\u30b9\u30c8\n}<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"9e0081e1-8696-49bb-aa80-1325acc89f38\">Identifiable\u30d7\u30ed\u30c8\u30b3\u30eb<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"941039a1-3951-4378-8cb9-a2b98ccd1976\">Identifiable \u30d7\u30ed\u30c8\u30b3\u30eb\u306b\u6e96\u62e0\u3059\u308b\u3053\u3068\u3067\u3001\u3053\u306e\u69cb\u9020\u4f53\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306f\u4e00\u610f\u306eID\u3092\u6301\u3061\u3001SwiftUI\u306e\u30ea\u30b9\u30c8\u3084ForEach\u30d3\u30e5\u30fc\u3067\u4f7f\u7528\u3059\u308b\u969b\u306b\u7279\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u306e\u30d7\u30ed\u30c8\u30b3\u30eb\u306b\u306f\u3001id\u3068\u3044\u3046\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6301\u3064\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3984ca2c-5d06-4b9e-bf4d-6fd1411e9582\">Identifiable\u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u4ed8\u3051\u306a\u3044\u3068\u3001ForEach\u3084List\u3067\u30a8\u30e9\u30fc\u3068\u306a\u308b<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"15b07266-2f9c-4a78-b989-8155c0a92978\">Identifiable\u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u4ed8\u3051\u306a\u3044\u5834\u5408\u3001SwiftUI\u306eForEach\u3084List\u306a\u3069\u306e\u30d3\u30e5\u30fc\u3067\u3053\u306e\u69cb\u9020\u4f53\u3092\u4f7f\u7528\u3059\u308b\u969b\u306b\u3001\u4e00\u610f\u306b\u8b58\u5225\u3067\u304d\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6301\u305f\u306a\u3044\u305f\u3081\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002Identifiable\u30d7\u30ed\u30c8\u30b3\u30eb\u306f\u3001\u30ea\u30b9\u30c8\u30a2\u30a4\u30c6\u30e0\u3084\u305d\u306e\u4ed6\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5185\u306e\u8981\u7d20\u3092\u4e00\u610f\u306b\u8b58\u5225\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"cd0f3ada-4354-4cd2-8c9e-33b2850e28c9\">\u8cea\u554f\u30c7\u30fc\u30bf\u3092\u7ba1\u7406\u3059\u308b\u30af\u30e9\u30b9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"960dd36c-0ea3-4a4b-90ef-49a3b54e5ea2\">\u5909\u6570\u306e\u5909\u66f4\u3092\u691c\u77e5\u3057\u30d3\u30e5\u30fc\u3092\u81ea\u52d5\u66f4\u65b0\uff08ObservableObject\u30d7\u30ed\u30c8\u30b3\u30eb\uff09<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"8eb275b0-a27d-4f44-9a08-536f52dba93e\">ObservableObject \u30d7\u30ed\u30c8\u30b3\u30eb\u306b\u6e96\u62e0\u3059\u308b\u3053\u3068\u3067\u3001\u3053\u306e\u30af\u30e9\u30b9\u306fSwiftUI\u306e\u30d3\u30e5\u30fc\u306b\u5bfe\u3057\u3066\u30c7\u30fc\u30bf\u306e\u5909\u66f4\u3092\u901a\u77e5\u3067\u304d\u307e\u3059\u3002\u30d3\u30e5\u30fc\u306f\u3053\u306e\u5909\u66f4\u3092\u76e3\u8996\u3057\u3001\u81ea\u52d5\u7684\u306b\u66f4\u65b0\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30e2\u30c7\u30eb\u3068\u30d3\u30e5\u30fc\u306e\u9593\u306e\u30c7\u30fc\u30bf\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class QuizViewModel: ObservableObject {\n    @Published var questions: [QuizQuestion] = []\n    @Published var currentQuestionIndex = 0\n    @Published var score = 0\n    \n    init() {\n        loadCSV()\n    }\n    \n    func loadCSV() {\n        guard let path = Bundle.main.path(forResource: \"quiz_questions\", ofType: \"csv\") else {\n            print(\"CSV file not found\")\n            return\n        }\n        \n        do {\n            let data = try String(contentsOfFile: path)\n            let rows = data.components(separatedBy: \"\\n\")\n            for row in rows.dropFirst() {\n                let columns = row.components(separatedBy: \",\")\n                if columns.count == 6 {\n                    let question = columns[0]\n                    let correct = columns[1]\n                    let options = Array(columns[2...5])\n                    let quizQuestion = QuizQuestion(question: question, correct: correct, options: options.shuffled())\n                    questions.append(quizQuestion)\n                }\n            }\n            questions.shuffle()\n        } catch {\n            print(\"Error reading CSV file: \\(error)\")\n        }\n    }\n    \n    func answerQuestion(with answer: String) {\n        if questions[currentQuestionIndex].correct == answer {\n            score += 1\n        }\n        currentQuestionIndex += 1\n    }\n    \n    func restartQuiz() {\n        score = 0\n        currentQuestionIndex = 0\n        questions.shuffle()\n    }\n}<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"aa95e76e-a676-4acb-91c1-1abb08aac3fe\">@Published var questions: [QuizQuestion] = []<br><br>\u30af\u30a4\u30ba\u306e\u8cea\u554f\u3092\u683c\u7d0d\u3059\u308b\u914d\u5217\u3067\u3059\u3002@Published\u5c5e\u6027\u3092\u4ed8\u3051\u308b\u3053\u3068\u3067\u3001\u3053\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u304c\u5909\u66f4\u3055\u308c\u305f\u3068\u304d\u306b\u30d3\u30e5\u30fc\u304c\u81ea\u52d5\u7684\u306b\u66f4\u65b0\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"9f2769cd-117a-4ad8-9664-afa5332a8adc\">ObservableObject\u30d7\u30ed\u30c8\u30b3\u30eb\u3068@Published\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u3064\u3051\u306a\u3044\u3068\u3001\u30d3\u30e5\u30fc\u304c\u81ea\u52d5\u7684\u306b\u66f4\u65b0\u3055\u308c\u306a\u3044<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"0ac9c97a-eed9-4bc6-bccc-59ea58b9e041\">ObservableObject\u30d7\u30ed\u30c8\u30b3\u30eb\u3068@Published\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u7528\u3057\u306a\u3044\u5834\u5408\u3001\u6b21\u306e\u3088\u3046\u306a\u554f\u984c\u304c\u767a\u751f\u3057\u307e\u3059\u3002<br><strong>\u30d3\u30e5\u30fc\u306e\u66f4\u65b0\u304c\u3055\u308c\u306a\u3044<\/strong>: \u30c7\u30fc\u30bf\u30e2\u30c7\u30eb\u306e\u5909\u66f4\u304c\u30d3\u30e5\u30fc\u306b\u53cd\u6620\u3055\u308c\u305a\u3001\u30e6\u30fc\u30b6\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u304c\u6700\u65b0\u306e\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3057\u307e\u305b\u3093\u3002<br><strong>\u30c7\u30fc\u30bf\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u304c\u6a5f\u80fd\u3057\u306a\u3044<\/strong>: SwiftUI\u306e\u30c7\u30fc\u30bf\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u6a5f\u80fd\u304c\u52d5\u4f5c\u3057\u306a\u3044\u305f\u3081\u3001\u624b\u52d5\u3067\u30d3\u30e5\u30fc\u3092\u66f4\u65b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br><br><strong>ObservableObject\u30d7\u30ed\u30c8\u30b3\u30eb\u3068@Published\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u3046\u7406\u7531<\/strong><br><br>\u3053\u308c\u3089\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u306e\u5909\u66f4\u3092\u81ea\u52d5\u7684\u306b\u30d3\u30e5\u30fc\u306b\u53cd\u6620\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u30ea\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30e6\u30fc\u30b6\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u7c21\u5358\u306b\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306e\u3088\u3046\u306b\u3001ObservableObject\u3068@Published\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u5909\u66f4\u304c\u30d3\u30e5\u30fc\u306b\u81ea\u52d5\u7684\u306b\u53cd\u6620\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6b72f8ca-ffc2-4a9a-8f8f-02ecf5a904ca\">CSV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u51e6\u7406<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5bbbce99-a1a7-43d0-ae93-19d46b48de56\">CSV\u306e\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u306e\u53d6\u5f97<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">guard let path = Bundle.main.path(forResource: \"quiz_questions\", ofType: \"csv\") else {\n     print(\"CSV file not found\")\n     return\n}<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"eb853744-6bd9-4b5f-82af-0b9f500f0638\">\u3053\u306e\u30b3\u30fc\u30c9\u30b9\u30cb\u30da\u30c3\u30c8\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d0\u30f3\u30c9\u30eb\u5185\u306b\u542b\u307e\u308c\u308b\u30ea\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\uff08\u3053\u306e\u5834\u5408\u306f&#8221;quiz_questions.csv&#8221;\uff09\u306e\u30d1\u30b9\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u3053\u306e\u30b3\u30fc\u30c9\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3092\u884c\u3044\u307e\u3059\u3002<br><br>1. Bundle.main.path(forResource:ofType:)<br><br>Bundle.main\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30e1\u30a4\u30f3\u30d0\u30f3\u30c9\u30eb\u3092\u6307\u3057\u307e\u3059\u3002\u30d0\u30f3\u30c9\u30eb\u3068\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u542b\u307e\u308c\u308b\u30ea\u30bd\u30fc\u30b9\uff08\u753b\u50cf\u3001\u30c7\u30fc\u30bf\u30d5\u30a1\u30a4\u30eb\u3001\u30b9\u30c8\u30fc\u30ea\u30fc\u30dc\u30fc\u30c9\u306a\u3069\uff09\u3092\u307e\u3068\u3081\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3059\u3002path(forResource:ofType:)\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30d0\u30f3\u30c9\u30eb\u5185\u306e\u6307\u5b9a\u3055\u308c\u305f\u30ea\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002forResource: \u30ea\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u540d\u524d\uff08\u62e1\u5f35\u5b50\u3092\u542b\u307e\u306a\u3044\uff09\u3002<br>ofType: \u30ea\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u62e1\u5f35\u5b50\u3002<br><br><br>2. guard\u6587<br><br>guard\u6587\u306f\u3001\u6761\u4ef6\u304c\u6e80\u305f\u3055\u308c\u306a\u3044\u5834\u5408\u306b\u7279\u5b9a\u306e\u30d6\u30ed\u30c3\u30af\u3092\u5b9f\u884c\u3057\u3001\u95a2\u6570\u3084\u30e1\u30bd\u30c3\u30c9\u304b\u3089\u65e9\u671f\u306b\u30ea\u30bf\u30fc\u30f3\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u5834\u5408\u3001CSV\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u3092\u53d6\u5f97\u3067\u304d\u306a\u304b\u3063\u305f\u5834\u5408\u306b\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u3001\u30e1\u30bd\u30c3\u30c9\u304b\u3089\u30ea\u30bf\u30fc\u30f3\u3057\u307e\u3059\u3002<br><br>3. path\u306e\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u578b<br><br>path(forResource:ofType:)\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30ea\u30bd\u30fc\u30b9\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306bnil\u3092\u8fd4\u3059\u305f\u3081\u3001path\u306f\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u578b\u306b\u306a\u308a\u307e\u3059\u3002guard let\u69cb\u6587\u3092\u4f7f\u7528\u3057\u3066\u3001path\u304cnil\u3067\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"238f86f2-cd18-45db-8323-b7a875abaf42\">CSV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u51e6\u7406<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">        do {\n            let data = try String(contentsOfFile: path)\n            let rows = data.components(separatedBy: \"\\n\")\n            for row in rows.dropFirst() {\n                print(\"loop\")\n                let columns = row.components(separatedBy: \",\")\n                \n                print(columns.count)\n                if columns.count == 5 {\n                    \n                    let question = columns[0]\n                    let correct = columns[1]\n                    let options = Array(columns[1...4])\n                    let quizQuestion = QuizQuestion(question: question, correct: correct, options: options.shuffled())\n                    questions.append(quizQuestion)\n                }\n            }\n            questions.shuffle()\n        } catch {\n            print(\"Error reading CSV file: \\(error)\")\n        }<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"2fb0b464-25ee-47c3-916e-c8b18906de92\">\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001CSV\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u305d\u306e\u5185\u5bb9\u3092\u51e6\u7406\u3057\u3001\u30af\u30a4\u30ba\u306e\u8cea\u554f\u3068\u9078\u629e\u80a2\u3092\u683c\u7d0d\u3059\u308b\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u3002\u5404\u884c\u3092\u5206\u5272\u3057\u3066\u8cea\u554f\u3092\u4f5c\u6210\u3057\u3001\u305d\u308c\u3092\u914d\u5217\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002\u8a73\u7d30\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<br><br>1. do { &#8230; } catch { &#8230; }\u30d6\u30ed\u30c3\u30af<br><br>\u3053\u306e\u30d6\u30ed\u30c3\u30af\u306f\u3001\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u305f\u3081\u306e\u3082\u306e\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u4e2d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306b\u5bfe\u5fdc\u3057\u307e\u3059\u3002<br><br>2. let data = try String(contentsOfFile: path)<br><strong>\u5185\u5bb9<\/strong>: \u6307\u5b9a\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u304b\u3089\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u6587\u5b57\u5217\u3068\u3057\u3066\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<br><strong>try<\/strong>: \u4f8b\u5916\u304c\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001try\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<br><strong>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0<\/strong>: \u8aad\u307f\u8fbc\u307f\u306b\u5931\u6557\u3057\u305f\u5834\u5408\u3001catch\u30d6\u30ed\u30c3\u30af\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<br><br>3. let rows = data.components(separatedBy: &#8220;\\n&#8221;)<br><strong>\u5185\u5bb9<\/strong>: \u8aad\u307f\u8fbc\u3093\u3060\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u884c\u3054\u3068\u306b\u5206\u5272\u3057\u3001\u5404\u884c\u3092rows\u914d\u5217\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<br><strong>\u5206\u5272\u57fa\u6e96<\/strong>: \u6539\u884c\u6587\u5b57\uff08\\n\uff09\u3002<br><br>4. for row in rows.dropFirst()<br><strong>\u5185\u5bb9<\/strong>: \u6700\u521d\u306e\u884c\uff08\u901a\u5e38\u306f\u30d8\u30c3\u30c0\u884c\uff09\u3092\u9664\u5916\u3057\u3001\u5404\u30c7\u30fc\u30bf\u884c\u3092\u51e6\u7406\u3057\u307e\u3059\u3002<br><strong>dropFirst()<\/strong>: \u6700\u521d\u306e\u8981\u7d20\u3092\u9664\u5916\u3057\u307e\u3059\u3002<br><br>5. print(&#8220;loop&#8221;)<br><strong>\u5185\u5bb9<\/strong>: \u5404\u884c\u306e\u51e6\u7406\u304c\u958b\u59cb\u3055\u308c\u308b\u305f\u3073\u306b\u300cloop\u300d\u3068\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3057\u307e\u3059\u3002\u30c7\u30d0\u30c3\u30b0\u7528\u306e\u51fa\u529b\u3067\u3059\u3002<br><br>6. let columns = row.components(separatedBy: &#8220;,&#8221;)<br><strong>\u5185\u5bb9<\/strong>: \u5404\u884c\u3092\u30ab\u30f3\u30de\uff08,\uff09\u3067\u5206\u5272\u3057\u3001\u5404\u30d5\u30a3\u30fc\u30eb\u30c9\u3092columns\u914d\u5217\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<br><br>7. print(columns.count)<br><strong>\u5185\u5bb9<\/strong>: \u5404\u884c\u306e\u5217\u6570\u3092\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3057\u307e\u3059\u3002\u30c7\u30d0\u30c3\u30b0\u7528\u306e\u51fa\u529b\u3067\u3059\u3002<br><br>8. if columns.count == 5<br><strong>\u5185\u5bb9<\/strong>: \u5404\u884c\u306b5\u3064\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u3082\u3057\u305d\u3046\u3067\u306a\u3044\u5834\u5408\u3001\u305d\u306e\u884c\u306f\u7121\u8996\u3055\u308c\u307e\u3059\u3002<br><br>9. let question = columns[0]<br><strong>\u5185\u5bb9<\/strong>: \u6700\u521d\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8cea\u554f\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002<br><br>10. let correct = columns[1]<br><strong>\u5185\u5bb9<\/strong>: 2\u756a\u76ee\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u6b63\u3057\u3044\u7b54\u3048\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002<br><br>11. let options = Array(columns[1&#8230;4])<br><strong>\u5185\u5bb9<\/strong>: 2\u756a\u76ee\u304b\u30895\u756a\u76ee\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u9078\u629e\u80a2\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\uff08\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u7bc4\u56f2\u304c\u9593\u9055\u3063\u3066\u3044\u308b\u305f\u3081\u4fee\u6b63\u304c\u5fc5\u8981\u3067\u3059\u3002\u6b63\u3057\u304f\u306fcolumns[2&#8230;4]\uff09\u3002<br><br>12. let quizQuestion = QuizQuestion(question: question, correct: correct, options: options.shuffled())<br><strong>\u5185\u5bb9<\/strong>: QuizQuestion\u69cb\u9020\u4f53\u306e\u65b0\u3057\u3044\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u9078\u629e\u80a2\u306f\u30b7\u30e3\u30c3\u30d5\u30eb\u3055\u308c\u307e\u3059\u3002<br><br>13. questions.append(quizQuestion)<br><strong>\u5185\u5bb9<\/strong>: \u4f5c\u6210\u3057\u305fQuizQuestion\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092questions\u914d\u5217\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<br><br>14. questions.shuffle()<br><strong>\u5185\u5bb9<\/strong>: \u5168\u3066\u306e\u8cea\u554f\u3092\u30e9\u30f3\u30c0\u30e0\u306b\u4e26\u3079\u66ff\u3048\u307e\u3059\u3002<br><br>15. catch { print(&#8220;Error reading CSV file: \\(error)&#8221;) }<strong>\u5185\u5bb9<\/strong>: \u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u4e2d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306b\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"e74c99b4-19e7-4f19-bfd5-33b8235502a5\">\u914d\u5217\u306e\u8981\u7d20\u3092\u30b7\u30e3\u30c3\u30d5\u30eb\u3059\u308b<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">questions.shuffle()<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"653a6d56-9c96-4973-b383-50d8d2581376\">questions.shuffle() \u306f\u3001Swift\u306e\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u542b\u307e\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3001\u914d\u5217\u5185\u306e\u8981\u7d20\u3092\u30e9\u30f3\u30c0\u30e0\u306b\u4e26\u3079\u66ff\u3048\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u914d\u5217\u306e\u8981\u7d20\u306e\u9806\u5e8f\u304c\u30e9\u30f3\u30c0\u30e0\u306b\u5909\u66f4\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"055c7b59-be3a-4188-b351-0c53f7f1f799\">\u8cea\u554f\u6587\u3092\u8868\u793a\u3059\u308b\u30d3\u30e5\u30fc<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">                    let question = viewModel.questions[viewModel.currentQuestionIndex]\n                    Text(question.question)\n                        .font(.title)\n                        .padding()\n                    ForEach(question.options, id: \\.self) { option in\n                        Button(action: {\n                            viewModel.answerQuestion(with: option)\n                        }) {\n                            Text(option)\n                                .frame(maxWidth: .infinity)\n                                .padding()\n                                .background(Color.blue)\n                                .foregroundColor(.white)\n                                .cornerRadius(10)\n                        }\n                        .padding(.horizontal)\n                    }\n\n<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"ae78f4cc-1554-48be-9c23-9e1e1d0854f9\"><a href=\"https:\/\/assets.st-note.com\/img\/1717982896823-qXuC8cpcwX.png?width=2000&amp;height=2000&amp;fit=bounds&amp;quality=85\"><img decoding=\"async\" src=\"https:\/\/assets.st-note.com\/img\/1717982896823-qXuC8cpcwX.png?width=1200\" alt=\"\u753b\u50cf\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"e9c6e484-1840-47e2-baef-17d7c156ff90\">\u5404\u7a2e\u30b3\u30fc\u30c9\u306e\u8aac\u660e\u305d\u306e\uff11<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"59ab20c8-1841-438a-be9a-f5b386a3f7e5\">\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001SwiftUI\u3092\u4f7f\u7528\u3057\u3066\u30af\u30a4\u30ba\u306e\u8cea\u554f\u3068\u9078\u629e\u80a2\u3092\u8868\u793a\u3059\u308b\u30d3\u30e5\u30fc\u306e\u4e00\u90e8\u3067\u3059\u3002\u73fe\u5728\u306e\u8cea\u554f\u3092\u8868\u793a\u3057\u3001\u305d\u306e\u8cea\u554f\u306b\u5bfe\u3059\u308b\u8907\u6570\u306e\u9078\u629e\u80a2\u3092\u30dc\u30bf\u30f3\u3068\u3057\u3066\u8868\u793a\u3057\u307e\u3059\u3002\u305d\u308c\u305e\u308c\u306e\u9078\u629e\u80a2\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u9078\u629e\u3057\u305f\u7b54\u3048\u304c\u51e6\u7406\u3055\u308c\u307e\u3059\u3002<br><br>\u5404\u90e8\u5206\u306e\u8aac\u660e<br><br>1. let question = viewModel.questions[viewModel.currentQuestionIndex]<br><strong>\u5185\u5bb9<\/strong>: viewModel\u306equestions\u914d\u5217\u304b\u3089\u73fe\u5728\u306e\u8cea\u554f\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002currentQuestionIndex\u306f\u73fe\u5728\u8868\u793a\u3059\u3079\u304d\u8cea\u554f\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<br><br><br>2. Text(question.question)<br><strong>\u5185\u5bb9<\/strong>: \u73fe\u5728\u306e\u8cea\u554f\u30c6\u30ad\u30b9\u30c8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<br><strong>\u4fee\u98fe\u5b50<\/strong>:<br>.font(.title): \u30c6\u30ad\u30b9\u30c8\u306e\u30d5\u30a9\u30f3\u30c8\u30b5\u30a4\u30ba\u3092\u30bf\u30a4\u30c8\u30eb\u30b5\u30a4\u30ba\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br>.padding(): \u30c6\u30ad\u30b9\u30c8\u5468\u56f2\u306b\u30d1\u30c7\u30a3\u30f3\u30b0\uff08\u4f59\u767d\uff09\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"b37e71be-645b-401d-98c3-250f9f65215c\">\u30eb\u30fc\u30d7\u3067\u8cea\u554f\u306e\u9078\u629e\u80a2\u30924\u3064\u8868\u793a\u3059\u308b<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"e0dbac6a-95c3-4354-96b2-f3e853720087\">3. ForEach(question.options, id: \\.self) { option in &#8230; }<strong>\u5185\u5bb9<\/strong>: \u73fe\u5728\u306e\u8cea\u554f\u306b\u5bfe\u3059\u308b\u8907\u6570\u306e\u9078\u629e\u80a2\u3092\u53cd\u5fa9\u51e6\u7406\u3057\u3001\u305d\u308c\u305e\u308c\u306e\u9078\u629e\u80a2\u3092\u30dc\u30bf\u30f3\u3068\u3057\u3066\u8868\u793a\u3057\u307e\u3059\u3002<br><strong>\u5f15\u6570<\/strong>:<br>question.options: \u9078\u629e\u80a2\u306e\u914d\u5217\u3002<br>id: \\.self: \u5404\u9078\u629e\u80a2\u304c\u4e00\u610f\u3067\u3042\u308b\u3053\u3068\u3092\u4fdd\u8a3c\u3059\u308b\u305f\u3081\u306e\u8b58\u5225\u5b50\u3002\u6587\u5b57\u5217\u81ea\u4f53\u3092\u8b58\u5225\u5b50\u3068\u3057\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"111bdda2-5c88-4828-b584-6692d0748b47\">ForEach\u5185\u3067\u4f7f\u7528\u3055\u308c\u308bid: \\.self\u306f\u3001\u914d\u5217\u306e\u5404\u8981\u7d20\u3092\u4e00\u610f\u306b\u8b58\u5225\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\uff08struct QuizQuestion: Identifiable\u306eid\u3068\u306f\u95a2\u4fc2\u306a\u3057\uff09<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"35fdacfa-4368-4063-a75c-6a98249812f9\">\u4e0a\u8a18\u306eid: \\.self\u306f\u3001struct QuizQuestion: Identifiable\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308bid\u3068\u306f\u76f4<br>\u63a5\u95a2\u4fc2\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u4ee5\u4e0b\u306b\u305d\u308c\u305e\u308c\u306eid\u306e\u5f79\u5272\u3068\u95a2\u4fc2\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<br><br><strong>\u5f79\u5272<\/strong>: ForEach\u5185\u3067\u4f7f\u7528\u3055\u308c\u308bid: \\.self\u306f\u3001question.options\u914d\u5217\u306e\u5404\u8981\u7d20\uff08\u9078\u629e\u80a2\uff09\u81ea\u4f53\u304c\u4e00\u610f\u3067\u3042\u308b\u3068\u4eee\u5b9a\u3057\u3001\u305d\u306e\u8981\u7d20\u3092\u4e00\u610f\u306b\u8b58\u5225\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002self\u306f\u914d\u5217\u306e\u5404\u8981\u7d20\u3092\u305d\u306e\u307e\u307e\u8b58\u5225\u5b50\u3068\u3057\u3066\u4f7f\u7528\u3059\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002<br><strong>\u9069\u7528\u7bc4\u56f2<\/strong>: question.options\u914d\u5217\u306e\u5404\u8981\u7d20\uff08\u9078\u629e\u80a2\uff09\u306b\u9069\u7528\u3055\u308c\u307e\u3059\u3002\u5404\u9078\u629e\u80a2\u304c\u6587\u5b57\u5217\u3067\u3042\u308b\u5834\u5408\u3001\u6587\u5b57\u5217\u305d\u306e\u3082\u306e\u304c\u8b58\u5225\u5b50\u3068\u3057\u3066\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"d3c51dfa-5227-408b-bdde-ee1dc72b359f\">\u9078\u629e\u80a2\uff08\u30dc\u30bf\u30f3\uff09\u3092\u62bc\u4e0b\u3059\u308b\u3068\u3001\u30dc\u30bf\u30f3\u62bc\u4e0b\u6642\u7528\u306e\u51e6\u7406\u304c\u767a\u706b<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"225e4e89-2f1f-4ce2-b4d3-a91a22a9b059\">4. Button(action: { &#8230; }) { &#8230; }<br><strong>\u5185\u5bb9<\/strong>: \u9078\u629e\u80a2\u3054\u3068\u306b\u30dc\u30bf\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br><strong>\u5f15\u6570<\/strong>:<br>action: \u30dc\u30bf\u30f3\u304c\u62bc\u3055\u308c\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u308b\u30af\u30ed\u30fc\u30b8\u30e3\u3002\u3053\u3053\u3067\u306fviewModel.answerQuestion(with: option)\u304c\u547c\u3073\u51fa\u3055\u308c\u3001\u9078\u629e\u3057\u305f\u7b54\u3048\u304c\u51e6\u7406\u3055\u308c\u307e\u3059\u3002<br>label: \u30dc\u30bf\u30f3\u306e\u30e9\u30d9\u30eb\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u9078\u629e\u80a2\u306e\u30c6\u30ad\u30b9\u30c8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"486f8db1-d4c9-487a-a990-9b8e8f3e988e\">\u5404\u7a2e\u30b3\u30fc\u30c9\u306e\u8aac\u660e\u305d\u306e2<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"9eb3835e-da4a-47b8-b500-213464215fd2\">5. Text(option)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u30e9\u30d9\u30eb\u3068\u3057\u3066\u3001\u9078\u629e\u80a2\u306e\u30c6\u30ad\u30b9\u30c8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<br><br>6. .frame(maxWidth: .infinity)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u5e45\u3092\u6700\u5927\u9650\u306b\u5e83\u3052\u307e\u3059\u3002\u89aa\u30d3\u30e5\u30fc\u306e\u5e45\u3044\u3063\u3071\u3044\u306b\u5e83\u304c\u308a\u307e\u3059\u3002<br><br>7. .padding()<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u5185\u5074\u306b\u30d1\u30c7\u30a3\u30f3\u30b0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8\u3068\u30dc\u30bf\u30f3\u306e\u5883\u754c\u3068\u306e\u9593\u306b\u4f59\u767d\u3092\u4f5c\u308a\u307e\u3059\u3002<br><br>8. .background(Color.blue)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u80cc\u666f\u8272\u3092\u9752\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br><br>9. .foregroundColor(.white)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8\u8272\u3092\u767d\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br><br>10. .cornerRadius(10)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u89d2\u309210\u30dd\u30a4\u30f3\u30c8\u306e\u534a\u5f84\u3067\u4e38\u304f\u3057\u307e\u3059\u3002<br><br>11. .padding(.horizontal)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u5468\u56f2\u306b\u6c34\u5e73\u65b9\u5411\u306e\u30d1\u30c7\u30a3\u30f3\u30b0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u5de6\u53f3\u306b\u4f59\u767d\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"d5eed733-719e-4bd2-91f2-a32e77552298\">with\u306f\u3001Swift\u306e\u30e1\u30bd\u30c3\u30c9\u5ba3\u8a00\u306b\u304a\u3044\u3066\u5f15\u6570\u30e9\u30d9\u30eb\u3092\u6307\u5b9a\u3059\u308b\u305f\u3081\u306e\u30ad\u30fc\u30ef\u30fc\u30c9<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    func answerQuestion(with answer: String) {\n        if questions[currentQuestionIndex].correct == answer {\n            score += 1\n        }\n        currentQuestionIndex += 1\n    }<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"feb9eebb-6850-4c2d-be29-826033a46568\">\u5f15\u6570\u30e9\u30d9\u30eb\u306f\u3001\u30e1\u30bd\u30c3\u30c9\u3084\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u3068\u304d\u306b\u4f7f\u7528\u3059\u308b\u540d\u524d\u3067\u3059\u3002\u5f15\u6570\u30e9\u30d9\u30eb\u306f\u30e1\u30bd\u30c3\u30c9\u3084\u95a2\u6570\u306e\u5b9a\u7fa9\u3067\u6307\u5b9a\u3055\u308c\u3001\u5f15\u6570\u30e9\u30d9\u30eb\u3068\u5f15\u6570\u306e\u540d\u524d\u3092\u7570\u306a\u308b\u3082\u306e\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30e1\u30bd\u30c3\u30c9\u3084\u95a2\u6570\u3092\u3088\u308a\u8aad\u307f\u3084\u3059\u304f\u3001\u7406\u89e3\u3057\u3084\u3059\u304f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br><br>\u5f15\u6570\u30e9\u30d9\u30eb\u3068\u5f15\u6570\u540d\u3092\u4f7f\u3044\u5206\u3051\u308b\u7406\u7531<br><br>\u5f15\u6570\u30e9\u30d9\u30eb\u3068\u5f15\u6570\u540d\u3092\u4f7f\u3044\u5206\u3051\u308b\u7406\u7531\u306f\u3001\u30e1\u30bd\u30c3\u30c9\u306e\u8aad\u307f\u3084\u3059\u3055\u3068\u53ef\u8aad\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u305f\u3081\u3067\u3059\u3002<br><br><strong>\u5f15\u6570\u30e9\u30d9\u30eb<\/strong>: \u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3068\u304d\u306b\u3001\u5f15\u6570\u306e\u610f\u5473\u3092\u660e\u78ba\u306b\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<br><strong>\u5f15\u6570\u540d<\/strong>: \u30e1\u30bd\u30c3\u30c9\u306e\u5185\u90e8\u3067\u5f15\u6570\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"178201b5-9dcb-4d65-9a93-92f39399ca0b\">\u304a\u308f\u308a\u306b<\/h2>\n\n\n\n<p id=\"dbfd1a08-beea-43d9-9746-fa6b237b244b\">\u6700\u5f8c\u307e\u3067\u8aad\u3093\u3067\u9802\u304d\u3001\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01<br><br>ChatGPT\u306b\u52d5\u304f\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u6559\u3048\u3066\u3082\u3089\u3048\u3001\u308f\u304b\u3089\u306a\u3044\u30ed\u30b8\u30c3\u30af\u306f\u3059\u3050\u306bChatGPT\u304c\u7b54\u3048\u3066\u304f\u308c\u308b\u306e\u3067\u3001\u52b9\u7387\u3088\u304f\u5b66\u7fd2\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\uff01<br>\u4eca\u5f8c\u3082ChatGPT\u3092\u4f7f\u7528\u3057\u3001\u8272\u3005\u306aiPhone\u3092\u4f5c\u3063\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"221c3b21-5d3b-4470-beef-5cddc8f5e6b4\">\u304a\u307e\u3051<\/h2>\n\n\n\n<p id=\"fdc4dce9-98d5-4ff7-a178-992cb8684ab2\">\u6700\u8fd1\u3001ChatGPT\u3092\u4f7f\u7528\u3057\u3001\u8272\u3005\u306a\u3053\u3068\u3092\u6a21\u7d22\u3057\u3066\u3044\u307e\u3059\u3002<br>\u3082\u3057\u3088\u3051\u308c\u3070\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3082\u898b\u3066\u9802\u3051\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\uff01<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">ChatGPT\u3092\u4f7f\u7528\u3057\u30011\u6642\u9593\u3067iPhone\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u307f\u305f\uff08swiftUI\uff09<\/h1>\n\n\n\n<p>10<\/p>\n\n\n\n<p><a href=\"https:\/\/note.com\/murasamejo\"><\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/note.com\/murasamejo\"><img decoding=\"async\" src=\"https:\/\/assets.st-note.com\/production\/uploads\/images\/149373125\/profile_50d1a4ec1aa6729bd5ac73d4a5781989.png?width=60\" alt=\"kinopi\"\/><\/a><\/figure>\n\n\n\n<p><a href=\"https:\/\/note.com\/murasamejo\">kinopi<\/a><\/p>\n\n\n\n<p>2024\u5e746\u670810\u65e5 12:33<\/p>\n\n\n\n<p id=\"07247b27-e709-437c-9baf-a0b4452b116a\">\u4eca\u56de\u306fChatGPT\u3067iPhone\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059\uff01<br>\u7d50\u69cb\u524d\u306bstory bored\u3092\u4f7f\u7528\u3057\u3001\u5c11\u3057\u3060\u3051\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u307f\u305f\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u304c\u3001swiftUI\u306f\u4f7f\u7528\u3057\u305f\u3053\u3068\u304c\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u3068\u308a\u3042\u3048\u305aVStack\u3068\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u9077\u79fb\u306e\u4ed5\u65b9\u3092\u52c9\u5f37\u3057\u3066\u3001\u65e9\u901fChatGPT\u3067\u30b3\u30fc\u30c6\u30a3\u30f3\u30b0\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\uff01<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"0ea776fd-bf56-40ab-8773-1584ecbb5e67\">\u30d7\u30ed\u30f3\u30d7\u30c8<\/h3>\n\n\n\n<p id=\"17c158d5-a90b-4794-b73a-d245cf3a6f66\">\u30af\u30a4\u30ba\u753b\u9762\u3092\u8868\u793a\u3057\u305f\u3044<br>\u30af\u30a4\u30ba\u554f\u984c\u306fCSV\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3001\u30af\u30a4\u30ba\u3092\u8868\u793a\u3059\u308b<br>\u30af\u30a4\u30ba\u306e\u5185\u5bb9\u306f\u82f1\u5358\u8a9e\u3092\u7b54\u3048\u308b\u30af\u30a4\u30ba\u3068\u3059\u308b<br>\u30af\u30a4\u30ba\u306f4\u629e\u3068\u3059\u308b<br>\u554f\u984c\u6570\u306f10\u554f\u3068\u3059\u308b<br>CSV\u30d5\u30a1\u30a4\u30eb\u306e\u554f\u984c\u306f\u30b5\u30f3\u30d7\u30eb\u306e\u554f\u984c\u3092\u3044\u304f\u3064\u304b\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"543f8f54-8599-4a21-b8a6-78c3fa7478b0\">ChatGPT\u306e\u56de\u7b54<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"428395a0-9552-43db-b801-697462d8cf32\">\u307e\u305a\u3001\u30af\u30a4\u30ba\u306e\u554f\u984c\u3092\u542b\u3080CSV\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u3001\u5404\u884c\u306b\u554f\u984c\u3001\u6b63\u89e3\u3001\u9078\u629e\u80a21\u3001\u9078\u629e\u80a22\u3001\u9078\u629e\u80a23\u3001\u9078\u629e\u80a24\u3092\u542b\u3080\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u30b5\u30f3\u30d7\u30eb\u306eCSV\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u793a\u3057\u307e\u3059\u3002<br><br><strong>\u30b5\u30f3\u30d7\u30ebCSV\u30d5\u30a1\u30a4\u30eb (quiz_questions.csv)<\/strong><\/p>\n<\/blockquote>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">question,correct,option1,option2,option3,option4\nWhat is the English word for \"\u72ac\"?,dog,cat,mouse,bird\nWhat is the English word for \"\u732b\"?,cat,dog,mouse,bird\nWhat is the English word for \"\u9ce5\"?,bird,cat,mouse,dog\nWhat is the English word for \"\u30cd\u30ba\u30df\"?,mouse,cat,bird,dog\nWhat is the English word for \"\u99ac\"?,horse,cow,sheep,goat\nWhat is the English word for \"\u725b\"?,cow,horse,sheep,goat\nWhat is the English word for \"\u7f8a\"?,sheep,horse,cow,goat\nWhat is the English word for \"\u5c71\u7f8a\"?,goat,horse,cow,sheep\nWhat is the English word for \"\u30e9\u30a4\u30aa\u30f3\"?,lion,tiger,leopard,cheetah\nWhat is the English word for \"\u30c8\u30e9\"?,tiger,lion,leopard,cheetah<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"91cfbfdf-0c24-4ab6-86d8-0565df1ecd46\">\u6b21\u306b\u3001SwiftUI\u3092\u4f7f\u7528\u3057\u3066\u3053\u306eCSV\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u3001\u30af\u30a4\u30ba\u753b\u9762\u3092\u8868\u793a\u3059\u308b\u30b3\u30fc\u30c9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br><br><strong>CSV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u3068\u30af\u30a4\u30ba\u8868\u793a\u306e\u30b3\u30fc\u30c9<\/strong><\/p>\n<\/blockquote>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import SwiftUI\nimport Foundation\n\nstruct QuizQuestion: Identifiable {\n    let id = UUID()\n    let question: String\n    let correct: String\n    let options: [String]\n}\n\nclass QuizViewModel: ObservableObject {\n    @Published var questions: [QuizQuestion] = []\n    @Published var currentQuestionIndex = 0\n    @Published var score = 0\n    \n    init() {\n        loadCSV()\n    }\n    \n    func loadCSV() {\n        guard let path = Bundle.main.path(forResource: \"quiz_questions\", ofType: \"csv\") else {\n            print(\"CSV file not found\")\n            return\n        }\n        \n        do {\n            let data = try String(contentsOfFile: path)\n            let rows = data.components(separatedBy: \"\\n\")\n            for row in rows.dropFirst() {\n                let columns = row.components(separatedBy: \",\")\n                if columns.count == 6 {\n                    let question = columns[0]\n                    let correct = columns[1]\n                    let options = Array(columns[2...5])\n                    let quizQuestion = QuizQuestion(question: question, correct: correct, options: options.shuffled())\n                    questions.append(quizQuestion)\n                }\n            }\n            questions.shuffle()\n        } catch {\n            print(\"Error reading CSV file: \\(error)\")\n        }\n    }\n    \n    func answerQuestion(with answer: String) {\n        if questions[currentQuestionIndex].correct == answer {\n            score += 1\n        }\n        currentQuestionIndex += 1\n    }\n    \n    func restartQuiz() {\n        score = 0\n        currentQuestionIndex = 0\n        questions.shuffle()\n    }\n}\n\nstruct QuizView: View {\n    @ObservedObject var viewModel = QuizViewModel()\n    \n    var body: some View {\n        NavigationView {\n            VStack {\n                if viewModel.currentQuestionIndex &lt; viewModel.questions.count {\n                    let question = viewModel.questions[viewModel.currentQuestionIndex]\n                    Text(question.question)\n                        .font(.title)\n                        .padding()\n                    ForEach(question.options, id: \\.self) { option in\n                        Button(action: {\n                            viewModel.answerQuestion(with: option)\n                        }) {\n                            Text(option)\n                                .frame(maxWidth: .infinity)\n                                .padding()\n                                .background(Color.blue)\n                                .foregroundColor(.white)\n                                .cornerRadius(10)\n                        }\n                        .padding(.horizontal)\n                    }\n                } else {\n                    Text(\"Quiz Completed!\")\n                        .font(.largeTitle)\n                        .padding()\n                    Text(\"Your score: \\(viewModel.score)\/\\(viewModel.questions.count)\")\n                        .font(.title)\n                        .padding()\n                    Button(action: {\n                        viewModel.restartQuiz()\n                    }) {\n                        Text(\"Restart Quiz\")\n                            .padding()\n                            .background(Color.green)\n                            .foregroundColor(.white)\n                            .cornerRadius(10)\n                    }\n                }\n            }\n            .navigationTitle(\"Quiz\")\n            .padding()\n        }\n    }\n}\n\nstruct ContentView: View {\n    var body: some View {\n        NavigationView {\n            VStack {\n                NavigationLink(destination: QuizView()) {\n                    Text(\"Start Quiz\")\n                        .foregroundColor(.white)\n                        .frame(width: UIScreen.main.bounds.width * 0.9)\n                        .padding()\n                        .background(Color.blue)\n                        .cornerRadius(10)\n                }\n                .padding()\n            }\n            .navigationTitle(\"Main View\")\n        }\n    }\n}\n\nstruct ContentView_Previews: PreviewProvider {\n    static var previews: some View {\n        ContentView()\n    }\n}\n<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"d3d09b8d-84d8-4524-b88b-06ea44d338ae\">\u52d5\u4f5c\u78ba\u8a8d<\/h3>\n\n\n\n<p id=\"fda70fb2-bb9c-44e2-9b5d-2a5c9e336c79\">\u591a\u5c11\u30d0\u30b0\u3082\u3042\u308a\u307e\u3057\u305f\u304c\u30011\u6642\u9593\u7a0b\u5ea6\u3067\u753b\u9762\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\uff01<br>\uff08csv\u306e\u30ab\u30e9\u30e0\u6570\u306f5\u500b\u3060\u304c\u30016\u500b\u306e\u30ed\u30b8\u30c3\u30af\u3068\u306a\u3063\u3066\u3044\u305f\u308a\u3002\u3002\uff09<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">                if columns.count == 6 { \/\/ \u30ed\u30b8\u30c3\u30af\u4e0d\u5099\u3002CSV\u306e\u30ab\u30e9\u30e0\u6570\u306f5\u500b\n                    let question = columns[0]\n                    let correct = columns[1]\n                    let options = Array(columns[2...5]) \/\/ \u30ed\u30b8\u30c3\u30af\u4e0d\u5099\u3002\n                    let quizQuestion = QuizQuestion(question: question, correct: correct, options: options.shuffled())\n                    questions.append(quizQuestion)\n                }<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"c9153c52-63fd-440c-83bd-834fa5b05a0a\"><a href=\"https:\/\/assets.st-note.com\/img\/1717987243715-YOALcy1LBP.png?width=2000&amp;height=2000&amp;fit=bounds&amp;quality=85\"><img decoding=\"async\" src=\"https:\/\/assets.st-note.com\/img\/1717987243715-YOALcy1LBP.png?width=1200\" alt=\"\u753b\u50cf\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\" id=\"d9ee0df4-568a-4749-987c-9b601df7d45b\"><a href=\"https:\/\/assets.st-note.com\/img\/1717987268917-uq9GjlHbwV.png?width=2000&amp;height=2000&amp;fit=bounds&amp;quality=85\"><img decoding=\"async\" src=\"https:\/\/assets.st-note.com\/img\/1717987268917-uq9GjlHbwV.png?width=1200\" alt=\"\u753b\u50cf\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\" id=\"0b58d8e2-7625-4de7-8622-394c0280d8db\"><a href=\"https:\/\/assets.st-note.com\/img\/1717987291849-ROgcoswhDP.png?width=2000&amp;height=2000&amp;fit=bounds&amp;quality=85\"><img decoding=\"async\" src=\"https:\/\/assets.st-note.com\/img\/1717987291849-ROgcoswhDP.png?width=1200\" alt=\"\u753b\u50cf\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"07c86d59-5d04-419e-8f34-6f5eefcd8870\">ChatGPT\u306b\u30b3\u30fc\u30c9\u306e\u5185\u5bb9\u3092\u6559\u3048\u3066\u3082\u3089\u3046<\/h2>\n\n\n\n<p id=\"ce1e66da-678c-4b4c-8f0d-2ca543f03769\">\u7121\u4e8b\u753b\u9762\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u306e\u3067\u3001\u6b21\u306b\u30ed\u30b8\u30c3\u30af\u306e\u5404\u30b9\u30c6\u30c3\u30d7\u306b\u3064\u3044\u3066ChatGPT\u306b\u6559\u3048\u3066\u3082\u3089\u304a\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"add18189-bc39-4795-880a-c064574ceae8\">\u8cea\u554f\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3059\u308b\u69cb\u9020\u4f53<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">struct QuizQuestion: Identifiable {\n    let id = UUID() \/\/ \u4e00\u610f\u306eID\u3092\u751f\u6210\n    let question: String \/\/ \u30af\u30a4\u30ba\u306e\u8cea\u554f\n    let correct: String \/\/ \u6b63\u3057\u3044\u7b54\u3048\n    let options: [String] \/\/ \u9078\u629e\u80a2\u306e\u30ea\u30b9\u30c8\n}<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"9e0081e1-8696-49bb-aa80-1325acc89f38\">Identifiable\u30d7\u30ed\u30c8\u30b3\u30eb<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"941039a1-3951-4378-8cb9-a2b98ccd1976\">Identifiable \u30d7\u30ed\u30c8\u30b3\u30eb\u306b\u6e96\u62e0\u3059\u308b\u3053\u3068\u3067\u3001\u3053\u306e\u69cb\u9020\u4f53\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306f\u4e00\u610f\u306eID\u3092\u6301\u3061\u3001SwiftUI\u306e\u30ea\u30b9\u30c8\u3084ForEach\u30d3\u30e5\u30fc\u3067\u4f7f\u7528\u3059\u308b\u969b\u306b\u7279\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u306e\u30d7\u30ed\u30c8\u30b3\u30eb\u306b\u306f\u3001id\u3068\u3044\u3046\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6301\u3064\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3984ca2c-5d06-4b9e-bf4d-6fd1411e9582\">Identifiable\u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u4ed8\u3051\u306a\u3044\u3068\u3001ForEach\u3084List\u3067\u30a8\u30e9\u30fc\u3068\u306a\u308b<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"15b07266-2f9c-4a78-b989-8155c0a92978\">Identifiable\u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u4ed8\u3051\u306a\u3044\u5834\u5408\u3001SwiftUI\u306eForEach\u3084List\u306a\u3069\u306e\u30d3\u30e5\u30fc\u3067\u3053\u306e\u69cb\u9020\u4f53\u3092\u4f7f\u7528\u3059\u308b\u969b\u306b\u3001\u4e00\u610f\u306b\u8b58\u5225\u3067\u304d\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6301\u305f\u306a\u3044\u305f\u3081\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002Identifiable\u30d7\u30ed\u30c8\u30b3\u30eb\u306f\u3001\u30ea\u30b9\u30c8\u30a2\u30a4\u30c6\u30e0\u3084\u305d\u306e\u4ed6\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5185\u306e\u8981\u7d20\u3092\u4e00\u610f\u306b\u8b58\u5225\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"cd0f3ada-4354-4cd2-8c9e-33b2850e28c9\">\u8cea\u554f\u30c7\u30fc\u30bf\u3092\u7ba1\u7406\u3059\u308b\u30af\u30e9\u30b9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"960dd36c-0ea3-4a4b-90ef-49a3b54e5ea2\">\u5909\u6570\u306e\u5909\u66f4\u3092\u691c\u77e5\u3057\u30d3\u30e5\u30fc\u3092\u81ea\u52d5\u66f4\u65b0\uff08ObservableObject\u30d7\u30ed\u30c8\u30b3\u30eb\uff09<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"8eb275b0-a27d-4f44-9a08-536f52dba93e\">ObservableObject \u30d7\u30ed\u30c8\u30b3\u30eb\u306b\u6e96\u62e0\u3059\u308b\u3053\u3068\u3067\u3001\u3053\u306e\u30af\u30e9\u30b9\u306fSwiftUI\u306e\u30d3\u30e5\u30fc\u306b\u5bfe\u3057\u3066\u30c7\u30fc\u30bf\u306e\u5909\u66f4\u3092\u901a\u77e5\u3067\u304d\u307e\u3059\u3002\u30d3\u30e5\u30fc\u306f\u3053\u306e\u5909\u66f4\u3092\u76e3\u8996\u3057\u3001\u81ea\u52d5\u7684\u306b\u66f4\u65b0\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30e2\u30c7\u30eb\u3068\u30d3\u30e5\u30fc\u306e\u9593\u306e\u30c7\u30fc\u30bf\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class QuizViewModel: ObservableObject {\n    @Published var questions: [QuizQuestion] = []\n    @Published var currentQuestionIndex = 0\n    @Published var score = 0\n    \n    init() {\n        loadCSV()\n    }\n    \n    func loadCSV() {\n        guard let path = Bundle.main.path(forResource: \"quiz_questions\", ofType: \"csv\") else {\n            print(\"CSV file not found\")\n            return\n        }\n        \n        do {\n            let data = try String(contentsOfFile: path)\n            let rows = data.components(separatedBy: \"\\n\")\n            for row in rows.dropFirst() {\n                let columns = row.components(separatedBy: \",\")\n                if columns.count == 6 {\n                    let question = columns[0]\n                    let correct = columns[1]\n                    let options = Array(columns[2...5])\n                    let quizQuestion = QuizQuestion(question: question, correct: correct, options: options.shuffled())\n                    questions.append(quizQuestion)\n                }\n            }\n            questions.shuffle()\n        } catch {\n            print(\"Error reading CSV file: \\(error)\")\n        }\n    }\n    \n    func answerQuestion(with answer: String) {\n        if questions[currentQuestionIndex].correct == answer {\n            score += 1\n        }\n        currentQuestionIndex += 1\n    }\n    \n    func restartQuiz() {\n        score = 0\n        currentQuestionIndex = 0\n        questions.shuffle()\n    }\n}<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"aa95e76e-a676-4acb-91c1-1abb08aac3fe\">@Published var questions: [QuizQuestion] = []<br><br>\u30af\u30a4\u30ba\u306e\u8cea\u554f\u3092\u683c\u7d0d\u3059\u308b\u914d\u5217\u3067\u3059\u3002@Published\u5c5e\u6027\u3092\u4ed8\u3051\u308b\u3053\u3068\u3067\u3001\u3053\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u304c\u5909\u66f4\u3055\u308c\u305f\u3068\u304d\u306b\u30d3\u30e5\u30fc\u304c\u81ea\u52d5\u7684\u306b\u66f4\u65b0\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"9f2769cd-117a-4ad8-9664-afa5332a8adc\">ObservableObject\u30d7\u30ed\u30c8\u30b3\u30eb\u3068@Published\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u3064\u3051\u306a\u3044\u3068\u3001\u30d3\u30e5\u30fc\u304c\u81ea\u52d5\u7684\u306b\u66f4\u65b0\u3055\u308c\u306a\u3044<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"0ac9c97a-eed9-4bc6-bccc-59ea58b9e041\">ObservableObject\u30d7\u30ed\u30c8\u30b3\u30eb\u3068@Published\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u7528\u3057\u306a\u3044\u5834\u5408\u3001\u6b21\u306e\u3088\u3046\u306a\u554f\u984c\u304c\u767a\u751f\u3057\u307e\u3059\u3002<br><strong>\u30d3\u30e5\u30fc\u306e\u66f4\u65b0\u304c\u3055\u308c\u306a\u3044<\/strong>: \u30c7\u30fc\u30bf\u30e2\u30c7\u30eb\u306e\u5909\u66f4\u304c\u30d3\u30e5\u30fc\u306b\u53cd\u6620\u3055\u308c\u305a\u3001\u30e6\u30fc\u30b6\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u304c\u6700\u65b0\u306e\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3057\u307e\u305b\u3093\u3002<br><strong>\u30c7\u30fc\u30bf\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u304c\u6a5f\u80fd\u3057\u306a\u3044<\/strong>: SwiftUI\u306e\u30c7\u30fc\u30bf\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u6a5f\u80fd\u304c\u52d5\u4f5c\u3057\u306a\u3044\u305f\u3081\u3001\u624b\u52d5\u3067\u30d3\u30e5\u30fc\u3092\u66f4\u65b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br><br><strong>ObservableObject\u30d7\u30ed\u30c8\u30b3\u30eb\u3068@Published\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u3046\u7406\u7531<\/strong><br><br>\u3053\u308c\u3089\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u306e\u5909\u66f4\u3092\u81ea\u52d5\u7684\u306b\u30d3\u30e5\u30fc\u306b\u53cd\u6620\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u30ea\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30e6\u30fc\u30b6\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u7c21\u5358\u306b\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306e\u3088\u3046\u306b\u3001ObservableObject\u3068@Published\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u5909\u66f4\u304c\u30d3\u30e5\u30fc\u306b\u81ea\u52d5\u7684\u306b\u53cd\u6620\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6b72f8ca-ffc2-4a9a-8f8f-02ecf5a904ca\">CSV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u51e6\u7406<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5bbbce99-a1a7-43d0-ae93-19d46b48de56\">CSV\u306e\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u306e\u53d6\u5f97<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">guard let path = Bundle.main.path(forResource: \"quiz_questions\", ofType: \"csv\") else {\n     print(\"CSV file not found\")\n     return\n}<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"eb853744-6bd9-4b5f-82af-0b9f500f0638\">\u3053\u306e\u30b3\u30fc\u30c9\u30b9\u30cb\u30da\u30c3\u30c8\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d0\u30f3\u30c9\u30eb\u5185\u306b\u542b\u307e\u308c\u308b\u30ea\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\uff08\u3053\u306e\u5834\u5408\u306f&#8221;quiz_questions.csv&#8221;\uff09\u306e\u30d1\u30b9\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u3053\u306e\u30b3\u30fc\u30c9\u306e\u8a73\u7d30\u306a\u8aac\u660e\u3092\u884c\u3044\u307e\u3059\u3002<br><br>1. Bundle.main.path(forResource:ofType:)<br><br>Bundle.main\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30e1\u30a4\u30f3\u30d0\u30f3\u30c9\u30eb\u3092\u6307\u3057\u307e\u3059\u3002\u30d0\u30f3\u30c9\u30eb\u3068\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u542b\u307e\u308c\u308b\u30ea\u30bd\u30fc\u30b9\uff08\u753b\u50cf\u3001\u30c7\u30fc\u30bf\u30d5\u30a1\u30a4\u30eb\u3001\u30b9\u30c8\u30fc\u30ea\u30fc\u30dc\u30fc\u30c9\u306a\u3069\uff09\u3092\u307e\u3068\u3081\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3059\u3002path(forResource:ofType:)\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30d0\u30f3\u30c9\u30eb\u5185\u306e\u6307\u5b9a\u3055\u308c\u305f\u30ea\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002forResource: \u30ea\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u540d\u524d\uff08\u62e1\u5f35\u5b50\u3092\u542b\u307e\u306a\u3044\uff09\u3002<br>ofType: \u30ea\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u62e1\u5f35\u5b50\u3002<br><br><br>2. guard\u6587<br><br>guard\u6587\u306f\u3001\u6761\u4ef6\u304c\u6e80\u305f\u3055\u308c\u306a\u3044\u5834\u5408\u306b\u7279\u5b9a\u306e\u30d6\u30ed\u30c3\u30af\u3092\u5b9f\u884c\u3057\u3001\u95a2\u6570\u3084\u30e1\u30bd\u30c3\u30c9\u304b\u3089\u65e9\u671f\u306b\u30ea\u30bf\u30fc\u30f3\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u5834\u5408\u3001CSV\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u3092\u53d6\u5f97\u3067\u304d\u306a\u304b\u3063\u305f\u5834\u5408\u306b\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u3001\u30e1\u30bd\u30c3\u30c9\u304b\u3089\u30ea\u30bf\u30fc\u30f3\u3057\u307e\u3059\u3002<br><br>3. path\u306e\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u578b<br><br>path(forResource:ofType:)\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30ea\u30bd\u30fc\u30b9\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306bnil\u3092\u8fd4\u3059\u305f\u3081\u3001path\u306f\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u578b\u306b\u306a\u308a\u307e\u3059\u3002guard let\u69cb\u6587\u3092\u4f7f\u7528\u3057\u3066\u3001path\u304cnil\u3067\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"238f86f2-cd18-45db-8323-b7a875abaf42\">CSV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u51e6\u7406<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">        do {\n            let data = try String(contentsOfFile: path)\n            let rows = data.components(separatedBy: \"\\n\")\n            for row in rows.dropFirst() {\n                print(\"loop\")\n                let columns = row.components(separatedBy: \",\")\n                \n                print(columns.count)\n                if columns.count == 5 {\n                    \n                    let question = columns[0]\n                    let correct = columns[1]\n                    let options = Array(columns[1...4])\n                    let quizQuestion = QuizQuestion(question: question, correct: correct, options: options.shuffled())\n                    questions.append(quizQuestion)\n                }\n            }\n            questions.shuffle()\n        } catch {\n            print(\"Error reading CSV file: \\(error)\")\n        }<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"2fb0b464-25ee-47c3-916e-c8b18906de92\">\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001CSV\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u305d\u306e\u5185\u5bb9\u3092\u51e6\u7406\u3057\u3001\u30af\u30a4\u30ba\u306e\u8cea\u554f\u3068\u9078\u629e\u80a2\u3092\u683c\u7d0d\u3059\u308b\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u3002\u5404\u884c\u3092\u5206\u5272\u3057\u3066\u8cea\u554f\u3092\u4f5c\u6210\u3057\u3001\u305d\u308c\u3092\u914d\u5217\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002\u8a73\u7d30\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<br><br>1. do { &#8230; } catch { &#8230; }\u30d6\u30ed\u30c3\u30af<br><br>\u3053\u306e\u30d6\u30ed\u30c3\u30af\u306f\u3001\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u305f\u3081\u306e\u3082\u306e\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u4e2d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306b\u5bfe\u5fdc\u3057\u307e\u3059\u3002<br><br>2. let data = try String(contentsOfFile: path)<br><strong>\u5185\u5bb9<\/strong>: \u6307\u5b9a\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u304b\u3089\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u6587\u5b57\u5217\u3068\u3057\u3066\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<br><strong>try<\/strong>: \u4f8b\u5916\u304c\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001try\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<br><strong>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0<\/strong>: \u8aad\u307f\u8fbc\u307f\u306b\u5931\u6557\u3057\u305f\u5834\u5408\u3001catch\u30d6\u30ed\u30c3\u30af\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<br><br>3. let rows = data.components(separatedBy: &#8220;\\n&#8221;)<br><strong>\u5185\u5bb9<\/strong>: \u8aad\u307f\u8fbc\u3093\u3060\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u884c\u3054\u3068\u306b\u5206\u5272\u3057\u3001\u5404\u884c\u3092rows\u914d\u5217\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<br><strong>\u5206\u5272\u57fa\u6e96<\/strong>: \u6539\u884c\u6587\u5b57\uff08\\n\uff09\u3002<br><br>4. for row in rows.dropFirst()<br><strong>\u5185\u5bb9<\/strong>: \u6700\u521d\u306e\u884c\uff08\u901a\u5e38\u306f\u30d8\u30c3\u30c0\u884c\uff09\u3092\u9664\u5916\u3057\u3001\u5404\u30c7\u30fc\u30bf\u884c\u3092\u51e6\u7406\u3057\u307e\u3059\u3002<br><strong>dropFirst()<\/strong>: \u6700\u521d\u306e\u8981\u7d20\u3092\u9664\u5916\u3057\u307e\u3059\u3002<br><br>5. print(&#8220;loop&#8221;)<br><strong>\u5185\u5bb9<\/strong>: \u5404\u884c\u306e\u51e6\u7406\u304c\u958b\u59cb\u3055\u308c\u308b\u305f\u3073\u306b\u300cloop\u300d\u3068\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3057\u307e\u3059\u3002\u30c7\u30d0\u30c3\u30b0\u7528\u306e\u51fa\u529b\u3067\u3059\u3002<br><br>6. let columns = row.components(separatedBy: &#8220;,&#8221;)<br><strong>\u5185\u5bb9<\/strong>: \u5404\u884c\u3092\u30ab\u30f3\u30de\uff08,\uff09\u3067\u5206\u5272\u3057\u3001\u5404\u30d5\u30a3\u30fc\u30eb\u30c9\u3092columns\u914d\u5217\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<br><br>7. print(columns.count)<br><strong>\u5185\u5bb9<\/strong>: \u5404\u884c\u306e\u5217\u6570\u3092\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3057\u307e\u3059\u3002\u30c7\u30d0\u30c3\u30b0\u7528\u306e\u51fa\u529b\u3067\u3059\u3002<br><br>8. if columns.count == 5<br><strong>\u5185\u5bb9<\/strong>: \u5404\u884c\u306b5\u3064\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u3082\u3057\u305d\u3046\u3067\u306a\u3044\u5834\u5408\u3001\u305d\u306e\u884c\u306f\u7121\u8996\u3055\u308c\u307e\u3059\u3002<br><br>9. let question = columns[0]<br><strong>\u5185\u5bb9<\/strong>: \u6700\u521d\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8cea\u554f\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002<br><br>10. let correct = columns[1]<br><strong>\u5185\u5bb9<\/strong>: 2\u756a\u76ee\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u6b63\u3057\u3044\u7b54\u3048\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002<br><br>11. let options = Array(columns[1&#8230;4])<br><strong>\u5185\u5bb9<\/strong>: 2\u756a\u76ee\u304b\u30895\u756a\u76ee\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u9078\u629e\u80a2\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\uff08\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u7bc4\u56f2\u304c\u9593\u9055\u3063\u3066\u3044\u308b\u305f\u3081\u4fee\u6b63\u304c\u5fc5\u8981\u3067\u3059\u3002\u6b63\u3057\u304f\u306fcolumns[2&#8230;4]\uff09\u3002<br><br>12. let quizQuestion = QuizQuestion(question: question, correct: correct, options: options.shuffled())<br><strong>\u5185\u5bb9<\/strong>: QuizQuestion\u69cb\u9020\u4f53\u306e\u65b0\u3057\u3044\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u9078\u629e\u80a2\u306f\u30b7\u30e3\u30c3\u30d5\u30eb\u3055\u308c\u307e\u3059\u3002<br><br>13. questions.append(quizQuestion)<br><strong>\u5185\u5bb9<\/strong>: \u4f5c\u6210\u3057\u305fQuizQuestion\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092questions\u914d\u5217\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<br><br>14. questions.shuffle()<br><strong>\u5185\u5bb9<\/strong>: \u5168\u3066\u306e\u8cea\u554f\u3092\u30e9\u30f3\u30c0\u30e0\u306b\u4e26\u3079\u66ff\u3048\u307e\u3059\u3002<br><br>15. catch { print(&#8220;Error reading CSV file: \\(error)&#8221;) }<strong>\u5185\u5bb9<\/strong>: \u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u4e2d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306b\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"e74c99b4-19e7-4f19-bfd5-33b8235502a5\">\u914d\u5217\u306e\u8981\u7d20\u3092\u30b7\u30e3\u30c3\u30d5\u30eb\u3059\u308b<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">questions.shuffle()<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"653a6d56-9c96-4973-b383-50d8d2581376\">questions.shuffle() \u306f\u3001Swift\u306e\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u542b\u307e\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3001\u914d\u5217\u5185\u306e\u8981\u7d20\u3092\u30e9\u30f3\u30c0\u30e0\u306b\u4e26\u3079\u66ff\u3048\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u914d\u5217\u306e\u8981\u7d20\u306e\u9806\u5e8f\u304c\u30e9\u30f3\u30c0\u30e0\u306b\u5909\u66f4\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"055c7b59-be3a-4188-b351-0c53f7f1f799\">\u8cea\u554f\u6587\u3092\u8868\u793a\u3059\u308b\u30d3\u30e5\u30fc<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">                    let question = viewModel.questions[viewModel.currentQuestionIndex]\n                    Text(question.question)\n                        .font(.title)\n                        .padding()\n                    ForEach(question.options, id: \\.self) { option in\n                        Button(action: {\n                            viewModel.answerQuestion(with: option)\n                        }) {\n                            Text(option)\n                                .frame(maxWidth: .infinity)\n                                .padding()\n                                .background(Color.blue)\n                                .foregroundColor(.white)\n                                .cornerRadius(10)\n                        }\n                        .padding(.horizontal)\n                    }\n\n<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"ae78f4cc-1554-48be-9c23-9e1e1d0854f9\"><a href=\"https:\/\/assets.st-note.com\/img\/1717982896823-qXuC8cpcwX.png?width=2000&amp;height=2000&amp;fit=bounds&amp;quality=85\"><img decoding=\"async\" src=\"https:\/\/assets.st-note.com\/img\/1717982896823-qXuC8cpcwX.png?width=1200\" alt=\"\u753b\u50cf\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"e9c6e484-1840-47e2-baef-17d7c156ff90\">\u5404\u7a2e\u30b3\u30fc\u30c9\u306e\u8aac\u660e\u305d\u306e\uff11<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"59ab20c8-1841-438a-be9a-f5b386a3f7e5\">\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001SwiftUI\u3092\u4f7f\u7528\u3057\u3066\u30af\u30a4\u30ba\u306e\u8cea\u554f\u3068\u9078\u629e\u80a2\u3092\u8868\u793a\u3059\u308b\u30d3\u30e5\u30fc\u306e\u4e00\u90e8\u3067\u3059\u3002\u73fe\u5728\u306e\u8cea\u554f\u3092\u8868\u793a\u3057\u3001\u305d\u306e\u8cea\u554f\u306b\u5bfe\u3059\u308b\u8907\u6570\u306e\u9078\u629e\u80a2\u3092\u30dc\u30bf\u30f3\u3068\u3057\u3066\u8868\u793a\u3057\u307e\u3059\u3002\u305d\u308c\u305e\u308c\u306e\u9078\u629e\u80a2\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u9078\u629e\u3057\u305f\u7b54\u3048\u304c\u51e6\u7406\u3055\u308c\u307e\u3059\u3002<br><br>\u5404\u90e8\u5206\u306e\u8aac\u660e<br><br>1. let question = viewModel.questions[viewModel.currentQuestionIndex]<br><strong>\u5185\u5bb9<\/strong>: viewModel\u306equestions\u914d\u5217\u304b\u3089\u73fe\u5728\u306e\u8cea\u554f\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002currentQuestionIndex\u306f\u73fe\u5728\u8868\u793a\u3059\u3079\u304d\u8cea\u554f\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<br><br><br>2. Text(question.question)<br><strong>\u5185\u5bb9<\/strong>: \u73fe\u5728\u306e\u8cea\u554f\u30c6\u30ad\u30b9\u30c8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<br><strong>\u4fee\u98fe\u5b50<\/strong>:<br>.font(.title): \u30c6\u30ad\u30b9\u30c8\u306e\u30d5\u30a9\u30f3\u30c8\u30b5\u30a4\u30ba\u3092\u30bf\u30a4\u30c8\u30eb\u30b5\u30a4\u30ba\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br>.padding(): \u30c6\u30ad\u30b9\u30c8\u5468\u56f2\u306b\u30d1\u30c7\u30a3\u30f3\u30b0\uff08\u4f59\u767d\uff09\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"b37e71be-645b-401d-98c3-250f9f65215c\">\u30eb\u30fc\u30d7\u3067\u8cea\u554f\u306e\u9078\u629e\u80a2\u30924\u3064\u8868\u793a\u3059\u308b<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"e0dbac6a-95c3-4354-96b2-f3e853720087\">3. ForEach(question.options, id: \\.self) { option in &#8230; }<strong>\u5185\u5bb9<\/strong>: \u73fe\u5728\u306e\u8cea\u554f\u306b\u5bfe\u3059\u308b\u8907\u6570\u306e\u9078\u629e\u80a2\u3092\u53cd\u5fa9\u51e6\u7406\u3057\u3001\u305d\u308c\u305e\u308c\u306e\u9078\u629e\u80a2\u3092\u30dc\u30bf\u30f3\u3068\u3057\u3066\u8868\u793a\u3057\u307e\u3059\u3002<br><strong>\u5f15\u6570<\/strong>:<br>question.options: \u9078\u629e\u80a2\u306e\u914d\u5217\u3002<br>id: \\.self: \u5404\u9078\u629e\u80a2\u304c\u4e00\u610f\u3067\u3042\u308b\u3053\u3068\u3092\u4fdd\u8a3c\u3059\u308b\u305f\u3081\u306e\u8b58\u5225\u5b50\u3002\u6587\u5b57\u5217\u81ea\u4f53\u3092\u8b58\u5225\u5b50\u3068\u3057\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"111bdda2-5c88-4828-b584-6692d0748b47\">ForEach\u5185\u3067\u4f7f\u7528\u3055\u308c\u308bid: \\.self\u306f\u3001\u914d\u5217\u306e\u5404\u8981\u7d20\u3092\u4e00\u610f\u306b\u8b58\u5225\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\uff08struct QuizQuestion: Identifiable\u306eid\u3068\u306f\u95a2\u4fc2\u306a\u3057\uff09<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"35fdacfa-4368-4063-a75c-6a98249812f9\">\u4e0a\u8a18\u306eid: \\.self\u306f\u3001struct QuizQuestion: Identifiable\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308bid\u3068\u306f\u76f4<br>\u63a5\u95a2\u4fc2\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u4ee5\u4e0b\u306b\u305d\u308c\u305e\u308c\u306eid\u306e\u5f79\u5272\u3068\u95a2\u4fc2\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<br><br><strong>\u5f79\u5272<\/strong>: ForEach\u5185\u3067\u4f7f\u7528\u3055\u308c\u308bid: \\.self\u306f\u3001question.options\u914d\u5217\u306e\u5404\u8981\u7d20\uff08\u9078\u629e\u80a2\uff09\u81ea\u4f53\u304c\u4e00\u610f\u3067\u3042\u308b\u3068\u4eee\u5b9a\u3057\u3001\u305d\u306e\u8981\u7d20\u3092\u4e00\u610f\u306b\u8b58\u5225\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002self\u306f\u914d\u5217\u306e\u5404\u8981\u7d20\u3092\u305d\u306e\u307e\u307e\u8b58\u5225\u5b50\u3068\u3057\u3066\u4f7f\u7528\u3059\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002<br><strong>\u9069\u7528\u7bc4\u56f2<\/strong>: question.options\u914d\u5217\u306e\u5404\u8981\u7d20\uff08\u9078\u629e\u80a2\uff09\u306b\u9069\u7528\u3055\u308c\u307e\u3059\u3002\u5404\u9078\u629e\u80a2\u304c\u6587\u5b57\u5217\u3067\u3042\u308b\u5834\u5408\u3001\u6587\u5b57\u5217\u305d\u306e\u3082\u306e\u304c\u8b58\u5225\u5b50\u3068\u3057\u3066\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"d3c51dfa-5227-408b-bdde-ee1dc72b359f\">\u9078\u629e\u80a2\uff08\u30dc\u30bf\u30f3\uff09\u3092\u62bc\u4e0b\u3059\u308b\u3068\u3001\u30dc\u30bf\u30f3\u62bc\u4e0b\u6642\u7528\u306e\u51e6\u7406\u304c\u767a\u706b<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"225e4e89-2f1f-4ce2-b4d3-a91a22a9b059\">4. Button(action: { &#8230; }) { &#8230; }<br><strong>\u5185\u5bb9<\/strong>: \u9078\u629e\u80a2\u3054\u3068\u306b\u30dc\u30bf\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br><strong>\u5f15\u6570<\/strong>:<br>action: \u30dc\u30bf\u30f3\u304c\u62bc\u3055\u308c\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u308b\u30af\u30ed\u30fc\u30b8\u30e3\u3002\u3053\u3053\u3067\u306fviewModel.answerQuestion(with: option)\u304c\u547c\u3073\u51fa\u3055\u308c\u3001\u9078\u629e\u3057\u305f\u7b54\u3048\u304c\u51e6\u7406\u3055\u308c\u307e\u3059\u3002<br>label: \u30dc\u30bf\u30f3\u306e\u30e9\u30d9\u30eb\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u9078\u629e\u80a2\u306e\u30c6\u30ad\u30b9\u30c8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"486f8db1-d4c9-487a-a990-9b8e8f3e988e\">\u5404\u7a2e\u30b3\u30fc\u30c9\u306e\u8aac\u660e\u305d\u306e2<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"9eb3835e-da4a-47b8-b500-213464215fd2\">5. Text(option)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u30e9\u30d9\u30eb\u3068\u3057\u3066\u3001\u9078\u629e\u80a2\u306e\u30c6\u30ad\u30b9\u30c8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<br><br>6. .frame(maxWidth: .infinity)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u5e45\u3092\u6700\u5927\u9650\u306b\u5e83\u3052\u307e\u3059\u3002\u89aa\u30d3\u30e5\u30fc\u306e\u5e45\u3044\u3063\u3071\u3044\u306b\u5e83\u304c\u308a\u307e\u3059\u3002<br><br>7. .padding()<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u5185\u5074\u306b\u30d1\u30c7\u30a3\u30f3\u30b0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8\u3068\u30dc\u30bf\u30f3\u306e\u5883\u754c\u3068\u306e\u9593\u306b\u4f59\u767d\u3092\u4f5c\u308a\u307e\u3059\u3002<br><br>8. .background(Color.blue)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u80cc\u666f\u8272\u3092\u9752\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br><br>9. .foregroundColor(.white)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u30c6\u30ad\u30b9\u30c8\u8272\u3092\u767d\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br><br>10. .cornerRadius(10)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u89d2\u309210\u30dd\u30a4\u30f3\u30c8\u306e\u534a\u5f84\u3067\u4e38\u304f\u3057\u307e\u3059\u3002<br><br>11. .padding(.horizontal)<strong>\u5185\u5bb9<\/strong>: \u30dc\u30bf\u30f3\u306e\u5468\u56f2\u306b\u6c34\u5e73\u65b9\u5411\u306e\u30d1\u30c7\u30a3\u30f3\u30b0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u5de6\u53f3\u306b\u4f59\u767d\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"d5eed733-719e-4bd2-91f2-a32e77552298\">with\u306f\u3001Swift\u306e\u30e1\u30bd\u30c3\u30c9\u5ba3\u8a00\u306b\u304a\u3044\u3066\u5f15\u6570\u30e9\u30d9\u30eb\u3092\u6307\u5b9a\u3059\u308b\u305f\u3081\u306e\u30ad\u30fc\u30ef\u30fc\u30c9<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    func answerQuestion(with answer: String) {\n        if questions[currentQuestionIndex].correct == answer {\n            score += 1\n        }\n        currentQuestionIndex += 1\n    }<\/pre>\n\n\n\n<p>copy<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"feb9eebb-6850-4c2d-be29-826033a46568\">\u5f15\u6570\u30e9\u30d9\u30eb\u306f\u3001\u30e1\u30bd\u30c3\u30c9\u3084\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u3068\u304d\u306b\u4f7f\u7528\u3059\u308b\u540d\u524d\u3067\u3059\u3002\u5f15\u6570\u30e9\u30d9\u30eb\u306f\u30e1\u30bd\u30c3\u30c9\u3084\u95a2\u6570\u306e\u5b9a\u7fa9\u3067\u6307\u5b9a\u3055\u308c\u3001\u5f15\u6570\u30e9\u30d9\u30eb\u3068\u5f15\u6570\u306e\u540d\u524d\u3092\u7570\u306a\u308b\u3082\u306e\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30e1\u30bd\u30c3\u30c9\u3084\u95a2\u6570\u3092\u3088\u308a\u8aad\u307f\u3084\u3059\u304f\u3001\u7406\u89e3\u3057\u3084\u3059\u304f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br><br>\u5f15\u6570\u30e9\u30d9\u30eb\u3068\u5f15\u6570\u540d\u3092\u4f7f\u3044\u5206\u3051\u308b\u7406\u7531<br><br>\u5f15\u6570\u30e9\u30d9\u30eb\u3068\u5f15\u6570\u540d\u3092\u4f7f\u3044\u5206\u3051\u308b\u7406\u7531\u306f\u3001\u30e1\u30bd\u30c3\u30c9\u306e\u8aad\u307f\u3084\u3059\u3055\u3068\u53ef\u8aad\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u305f\u3081\u3067\u3059\u3002<br><br><strong>\u5f15\u6570\u30e9\u30d9\u30eb<\/strong>: \u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3068\u304d\u306b\u3001\u5f15\u6570\u306e\u610f\u5473\u3092\u660e\u78ba\u306b\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<br><strong>\u5f15\u6570\u540d<\/strong>: \u30e1\u30bd\u30c3\u30c9\u306e\u5185\u90e8\u3067\u5f15\u6570\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"178201b5-9dcb-4d65-9a93-92f39399ca0b\">\u304a\u308f\u308a\u306b<\/h2>\n\n\n\n<p id=\"dbfd1a08-beea-43d9-9746-fa6b237b244b\">\u6700\u5f8c\u307e\u3067\u8aad\u3093\u3067\u9802\u304d\u3001\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01<br><br>ChatGPT\u306b\u52d5\u304f\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u6559\u3048\u3066\u3082\u3089\u3048\u3001\u308f\u304b\u3089\u306a\u3044\u30ed\u30b8\u30c3\u30af\u306f\u3059\u3050\u306bChatGPT\u304c\u7b54\u3048\u3066\u304f\u308c\u308b\u306e\u3067\u3001\u52b9\u7387\u3088\u304f\u5b66\u7fd2\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\uff01<br>\u4eca\u5f8c\u3082ChatGPT\u3092\u4f7f\u7528\u3057\u3001\u8272\u3005\u306aiPhone\u3092\u4f5c\u3063\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"221c3b21-5d3b-4470-beef-5cddc8f5e6b4\">\u304a\u307e\u3051<\/h2>\n\n\n\n<p id=\"fdc4dce9-98d5-4ff7-a178-992cb8684ab2\">\u6700\u8fd1\u3001ChatGPT\u3092\u4f7f\u7528\u3057\u3001\u8272\u3005\u306a\u3053\u3068\u3092\u6a21\u7d22\u3057\u3066\u3044\u307e\u3059\u3002<br>\u3082\u3057\u3088\u3051\u308c\u3070\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3082\u898b\u3066\u9802\u3051\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\uff01<\/p>\n<div class=\"veu_socialSet veu_socialSet-position-after veu_contentAddSection\"><script>window.twttr=(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src=\"https:\/\/platform.twitter.com\/widgets.js\";fjs.parentNode.insertBefore(js,fjs);t._e=[];t.ready=function(f){t._e.push(f);};return t;}(document,\"script\",\"twitter-wjs\"));<\/script><ul><li class=\"sb_facebook sb_icon\"><a class=\"sb_icon_inner\" href=\"\/\/www.facebook.com\/sharer.php?src=bm&u=https%3A%2F%2Fwww.elehobby.fun%2F%3Fp%3D4128&amp;t=%E5%AE%9F%E8%B7%B5%E3%81%A7%E3%81%8D%E3%81%9F%E9%9B%BB%E5%AD%90%E5%B7%A5%E4%BD%9C%E3%81%A8%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E9%96%8B%E7%99%BA\" target=\"_blank\" onclick=\"window.open(this.href,'FBwindow','width=650,height=450,menubar=no,toolbar=no,scrollbars=yes');return false;\"><span class=\"vk_icon_w_r_sns_fb icon_sns\"><\/span><span class=\"sns_txt\">Facebook<\/span><span class=\"veu_count_sns_fb\"><\/span><\/a><\/li><li class=\"sb_twitter sb_icon\"><a class=\"sb_icon_inner\" href=\"\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.elehobby.fun%2F%3Fp%3D4128&amp;text=%E5%AE%9F%E8%B7%B5%E3%81%A7%E3%81%8D%E3%81%9F%E9%9B%BB%E5%AD%90%E5%B7%A5%E4%BD%9C%E3%81%A8%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E9%96%8B%E7%99%BA\" target=\"_blank\" ><span class=\"vk_icon_w_r_sns_twitter icon_sns\"><\/span><span class=\"sns_txt\">twitter<\/span><\/a><\/li><li class=\"sb_hatena sb_icon\"><a class=\"sb_icon_inner\" href=\"\/\/b.hatena.ne.jp\/add?mode=confirm&url=https%3A%2F%2Fwww.elehobby.fun%2F%3Fp%3D4128&amp;title=%E5%AE%9F%E8%B7%B5%E3%81%A7%E3%81%8D%E3%81%9F%E9%9B%BB%E5%AD%90%E5%B7%A5%E4%BD%9C%E3%81%A8%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E9%96%8B%E7%99%BA\" target=\"_blank\"  onclick=\"window.open(this.href,'Hatenawindow','width=650,height=450,menubar=no,toolbar=no,scrollbars=yes');return false;\"><span class=\"vk_icon_w_r_sns_hatena icon_sns\"><\/span><span class=\"sns_txt\">Hatena<\/span><span class=\"veu_count_sns_hb\"><\/span><\/a><\/li><li class=\"sb_pocket sb_icon\"><a class=\"sb_icon_inner\"  href=\"\/\/getpocket.com\/edit?url=https%3A%2F%2Fwww.elehobby.fun%2F%3Fp%3D4128&title=%E5%AE%9F%E8%B7%B5%E3%81%A7%E3%81%8D%E3%81%9F%E9%9B%BB%E5%AD%90%E5%B7%A5%E4%BD%9C%E3%81%A8%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E9%96%8B%E7%99%BA\" target=\"_blank\"  onclick=\"window.open(this.href,'Pokcetwindow','width=650,height=450,menubar=no,toolbar=no,scrollbars=yes');return false;\"><span class=\"vk_icon_w_r_sns_pocket icon_sns\"><\/span><span class=\"sns_txt\">Pocket<\/span><span class=\"veu_count_sns_pocket\"><\/span><\/a><\/li><li class=\"sb_copy sb_icon\"><button class=\"copy-button sb_icon_inner\"data-clipboard-text=\"\u5b9f\u8df5\u3067\u304d\u305f\u96fb\u5b50\u5de5\u4f5c\u3068\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u958b\u767a https:\/\/www.elehobby.fun\/?p=4128\"><span class=\"vk_icon_w_r_sns_copy icon_sns\"><i class=\"fas fa-copy\"><\/i><\/span><span class=\"sns_txt\">Copy<\/span><\/button><\/li><\/ul><\/div><!-- [ \/.socialSet ] -->","protected":false},"excerpt":{"rendered":"<p>2024\u5e746\u670810\u65e5 12:33 \u4eca\u56de\u306fChatGPT\u3067iPhone\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059\uff01\u7d50\u69cb\u524d\u306bstory bored\u3092\u4f7f\u7528\u3057\u3001\u5c11\u3057\u3060\u3051\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u307f\u305f\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u304c\u3001swiftUI\u306f\u4f7f\u7528\u3057\u305f\u3053\u3068\u304c\u306a\u304b\u3063 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"vkexunit_cta_each_option":"","footnotes":""},"categories":[16],"tags":[],"class_list":["post-4128","post","type-post","status-publish","format-standard","hentry","category-electronicswork"],"_links":{"self":[{"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/posts\/4128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4128"}],"version-history":[{"count":1,"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/posts\/4128\/revisions"}],"predecessor-version":[{"id":4129,"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/posts\/4128\/revisions\/4129"}],"wp:attachment":[{"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}