I’m having trouble being able to load my completed app from chapter 1 of the 5th Edition iOS programming book. Every time I hit play for simulate, the apple load screen appears and then the app opens but it opens to a black screen. Here is my code:
ViewController.swift
// Take2
//
//
// Copyright © 2016 Big Nerd Ranch. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
questionlabel.text=questions[currentQuestionIndex]
}
@IBOutlet var questionlabel: UILabel!
@IBOutlet var answerlabel: UILabel!
let questions: [String] = ["From what is cognac made?",
"What is 7=7?",
"What is the capital of Vermont?",
"How old is Don?",
"What is Alex?"]
let answers: [String] = ["Grapes",
"14",
"Monteplier",
"24",
"A Little Boy"]
var currentQuestionIndex: Int = 0
@IBAction func showNextQuestion(sender: AnyObject){
currentQuestionIndex+=1
if currentQuestionIndex == questions.count{
currentQuestionIndex == 0
}
let question: String = questions[currentQuestionIndex]
questionlabel.text = question
answerlabel.text = "???"
}
@IBAction func showAnswer(sender: AnyObject){
let answer:String = answers[currentQuestionIndex]
answerlabel.text = answer
}
}