Swift: Why can I pass info from one IBAction to another, but not to a function - swift

I am trying to get the values for splitValue and tipPercent into the getSettings() at the bottom. Why can I get the values for both of those in the IBAction calculatePressed, but when I try to get the values into the function the value is nil. I am sooo confused. Thank you for the help!
#IBOutlet weak var billTextField: UITextField!
#IBOutlet weak var zeroPctButton: UIButton!
#IBOutlet weak var tenPctButton: UIButton!
#IBOutlet weak var twentyPctButton: UIButton!
#IBOutlet weak var splitNumberLabel: UILabel!
var tipChosen = ""
var totalPerPerson = ""
var tipPercent = ""
var splitValue = ""
#IBAction func tipChanged(_ sender: UIButton) {
tipPercent = sender.currentTitle!
if sender.isSelected == true {
return
}
zeroPctButton.isSelected = false
tenPctButton.isSelected = false
twentyPctButton.isSelected = false
sender.isSelected = true
if sender.currentTitle == "0%" {
tipChosen = "0.00"
} else if sender.currentTitle == "10%" {
tipChosen = "0.10"
} else if sender.currentTitle == "20%" {
tipChosen = "0.20"
}
billTextField.endEditing(true)
}
#IBAction func stepperValueChanged(_ sender: UIStepper) {
splitValue = String(Int(sender.value))
splitNumberLabel.text = String(Int(sender.value))
}
#IBAction func calculatePressed(_ sender: UIButton) {
let bill = Float(billTextField.text!)!
let tip = Float(tipChosen)!
let tax = bill * tip
let splitNumber = Float(splitNumberLabel.text!)
let total = (bill + tax) / Float(splitNumber!)
totalPerPerson = "$\(String(format: "%.2f", total))"
performSegue(withIdentifier: "goToTotal", sender: self)
}
func getSettings() -> String {
return "Split between \(splitValue) people, with a \(tipPercent) tip."
}

Ok, sorry it took me a bit, but I finally think I understand what I did.
class CalculatorViewController: UIViewController {
var tip = 0.0
var finalBill = ""
var split = 2
#IBOutlet weak var billTextField: UITextField!
#IBOutlet weak var zeroPctButton: UIButton!
#IBOutlet weak var tenPctButton: UIButton!
#IBOutlet weak var twentyPctButton: UIButton!
#IBOutlet weak var splitNumberLabel: UILabel!
#IBAction func tipChanged(_ sender: UIButton) {
if sender.isSelected == false {
sender.isSelected = false
} else if sender.isSelected == true {
sender.isSelected = true
}
zeroPctButton.isSelected = false
tenPctButton.isSelected = false
twentyPctButton.isSelected = false
sender.isSelected = true
billTextField.endEditing(true)
}
#IBAction func stepperValueChanged(_ sender: UIStepper) {
splitNumberLabel.text = Int(sender.value).description
}
#IBAction func calculatePressed(_ sender: UIButton) {
if zeroPctButton.isSelected == true {
tip = 0.0
} else if tenPctButton.isSelected == true {
tip = 0.1
} else if twentyPctButton.isSelected == true {
tip = 0.2
}
print(tip)
let bill = Double(billTextField.text!)
split = Int(Double(splitNumberLabel.text!)!)
if billTextField.text != "" {
let billWithTip = (bill! * tip) + bill!
let billWithTipSplit = billWithTip / Double(split)
finalBill = String(format: "%.2f", billWithTipSplit)
print(billWithTip)
}
self.performSegue(withIdentifier: "getResults", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "getResults" {
let destinationVC = segue.destination as! ResultsViewController
destinationVC.finalBill = finalBill
destinationVC.split = split
destinationVC.tip = tip
}
}
}
class ResultsViewController: UIViewController {
#IBOutlet weak var totalLabel: UILabel!
#IBOutlet weak var settingsLabel: UILabel!
var tip = 0.0
var split = 2
var finalBill = ""
override func viewDidLoad() {
super.viewDidLoad()
totalLabel.text = "$\(finalBill)"
settingsLabel.text = "Split between \(Int(split)) people, with a \(Int(tip * 100))% tip"
}
#IBAction func recalculatePressed(_ sender: UIButton) {
dismiss(animated: true, completion: nil)
}
}
I did what you suggested with the string and some minor calculations on the second view controller, changed the values of a few declared properties and got rid of the getSettings(). I was under the impression that I couldn't pass data without a return value from a function. Thank you for the help!

Related

increment/decrement the value of a label with two buttons

being new of swift means that I have issues with two buttons to increment the value of a label.I'm stuck because the increment button works but the decrement button doesn't. the value that I want to store inside the label decrease but the label doesn't update. here's the code, thank you
PS: all those isEnabled = true or false are only to disable the buttons to be able create a range from 0 to 5
class ViewController: UIViewController {
var incDec = 0;
#IBOutlet weak var countLbl: UILabel!
#IBOutlet weak var decBtn: UIButton!
#IBOutlet weak var incBtn: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
}
#IBAction func tapDec(_ sender: Any) {
if(incDec >= -1){
incDec -= 1;
self.countLbl.text = "\(incDec)"
decBtn.isEnabled = true
}
else{
self.countLbl.text = "\(incDec)"
decBtn.isEnabled = false
incBtn.isEnabled = true
}
}
#IBAction func tapInc(_ sender: Any) {
if(incDecVal < 5){
incDec += 1;
self.countLbl.text = "\(incDec)"
incBtn.isEnabled = true
}
else{
self.countLbl.text = "\(incDec)"
incBtn.isEnabled = false
decBtn.isEnabled = true
}
}
}
You have to modify the logic of enabling and disabling the buttons. Here is the code.
class ViewController: UIViewController {
var incDecVal = 0;
#IBOutlet weak var countLbl: UILabel!
#IBOutlet weak var decBtn: UIButton!
#IBOutlet weak var incBtn: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
countLbl.text = "\(incDecVal)"
}
#IBAction func tapDec(_ sender: Any) {
if(incDecVal > 0){
incDecVal = incDecVal - 1;
}
decBtn.isEnabled = incDecVal == 0 ? false : true
incBtn.isEnabled = true
self.countLbl.text = "\(incDecVal)"
}
#IBAction func tapInc(_ sender: Any) {
if(incDecVal <= 5) {
incDecVal = incDecVal + 1;
}
incBtn.isEnabled = incDecVal == 5 ? false : true
decBtn.isEnabled = true
self.countLbl.text = "\(incDecVal)"
}
}

Button only works when tapped twice

I have two buttons that each have a different segue to a different view controller, which is only triggered if certain conditions are met. For some reason, one of the buttons works fine, the other button has to be tapped twice in order for it to segue to the next view controller. The strange part is that the code for both buttons and segue if conditions are copied and pasted and slightly modified to go to their respective vcs. How can I get both buttons to work on the first tap?
So far I've tried:
reordering the button functions
reordering the segue functions
deleting/reconnecting the button
deleting/reconnecting the button
I believe it has something to do with the following code because when I remove it, this behavior is gone and a different but similar feature in the app with virtually the same code (minus the part below) works just fine. I do need it however due to testing for nil/errors:
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
return nextButton
}
Here is the code
import UIKit
class bathShowerMeasurementViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.hideKeyboardWhenTappedAround()
}
var nextButton = false
#IBOutlet weak var inchesButton: UIButton!
#IBAction func inches(_ sender: UIButton) {
if sender.isSelected {
sender.isSelected = false
} else {
sender.isSelected = true
}
}
#IBOutlet weak var unitError: UILabel!
#IBOutlet weak var centimeterButton: UIButton!
#IBAction func centimeter(_ sender: UIButton) {
if sender.isSelected {
sender.isSelected = false
} else {
sender.isSelected = true
}
}
#IBOutlet weak var length: UITextField!
#IBOutlet weak var lenghtError: UILabel!
#IBOutlet weak var width: UITextField!
#IBOutlet weak var widthError: UILabel!
#IBOutlet weak var height: UITextField!
#IBOutlet weak var heightError: UILabel!
#IBAction func showerCalc(_ sender: UIButton) {
let widthTub = Double(width.text!)
let lengthTub = Double(length.text!)
let heightTub = Double(height.text!)
var enableNextButton = true
if widthTub == nil || widthTub == 0.0 {
widthError.text = "Enter Width"
enableNextButton = false
}
if heightTub == nil || heightTub == 0.0 {
heightError.text = "Enter Height"
enableNextButton = false
}
if lengthTub == nil || lengthTub == 0.0 {
lenghtError.text = "Enter Length"
enableNextButton = false
}
switch (inchesButton.isSelected, centimeterButton.isSelected) {
case (false, false):
unitError.text = "Please Select A Unit"
enableNextButton = false
case (true, true):
unitError.text = "Only Select One Unit"
enableNextButton = false
default: break
}
nextButton = enableNextButton
}
#IBAction func goToShower(_ sender: UIButton) {
let widthTub = Double(width.text!)
let lengthTub = Double(length.text!)
let heightTub = Double(height.text!)
var enableNextButton = true
if widthTub == nil || widthTub == 0.0 {
widthError.text = "Enter Width"
enableNextButton = false
}
if heightTub == nil || heightTub == 0.0 {
heightError.text = "Enter Height"
enableNextButton = false
}
if lengthTub == nil || lengthTub == 0.0 {
lenghtError.text = "Enter Length"
enableNextButton = false
}
switch (inchesButton.isSelected, centimeterButton.isSelected) {
case (false, false):
unitError.text = "Please Select A Unit"
enableNextButton = false
case (true, true):
unitError.text = "Only Select One Unit"
enableNextButton = false
default: break
}
nextButton = enableNextButton
}
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
return nextButton
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let bathLength = Double(length.text!)
let bathWidth = Double(width.text!)
let bathHeight = Double(height.text!)
let water = Double(bathLength! * bathWidth! * bathHeight!)
if (segue.identifier == "showerCalc") {
if inchesButton.isSelected == true{
let bathWater = water / 231
let destinationVC = segue.destination as! showerFillMethodViewController
destinationVC.bathFlow = String(bathWater)
}
if centimeterButton.isSelected == true{
let bathWater = water / 3785.41
let destinationVC = segue.destination as! showerFillMethodViewController
destinationVC.bathFlow = String(bathWater)
}
}
if (segue.identifier == "showerTool") {
if inchesButton.isSelected == true{
let bathWater = water / 231
let destinationVC = segue.destination as! showerFlowMainViewController
destinationVC.bathFlow = String(bathWater)
}
if centimeterButton.isSelected == true{
let bathWater = water / 3785.41
let destinationVC = segue.destination as! showerFlowMainViewController
destinationVC.bathFlow = String(bathWater)
}
}
}
}

Force unwrapping nil optional for UIImageView when transitioning to view controller

I'm running into an error when transitioning to view controllers by overriding the built-in prepare() function in Swift. I have a UIImageView for backgrounds on my screens. Here is the code for two of the view controllers in question.
import UIKit
import FirebaseAuth
class HomeVC: UIViewController {
#IBOutlet weak var signOutButton: UIButton!
#IBOutlet weak var backgroundImageView: UIImageView!
#IBOutlet weak var friendsNavButton: UIButton!
#IBOutlet weak var homeNavButton: UIButton!
#IBOutlet weak var profileNavButton: UIButton!
#IBOutlet weak var bumpButton: UIButton!
#IBOutlet weak var welcomeLabel: UILabel!
#IBOutlet weak var doNotDisturbLabel: UILabel!
#IBOutlet weak var doNotDisturbButton: UIButton!
var userName = ""
var dndIsOn: Bool = false
#IBAction func dndToggled(_ sender: Any) {
dndIsOn = !dndIsOn
User.current.available = !dndIsOn
FirestoreService.db.collection(Constants.Firestore.Collections.users).document(User.current.uid).updateData([Constants.Firestore.Keys.available : !dndIsOn])
if dndIsOn {
print("DND is on!")
setupDNDUI()
} else if !dndIsOn {
print("DND is off!")
setupActiveUI()
}
}
#IBAction func signOutTapped(_ sender: Any) {
let firAuth = Auth.auth()
do {
try firAuth.signOut()
} catch let signOutError as NSError {
print ("Error signing out: %#", signOutError)
}
print("Successfully signed out")
}
#IBAction func bumpTapped(_ sender: Any) {
self.performSegue(withIdentifier: Constants.Segues.toCall, sender: self)
}
#IBAction func friendsNavTapped(_ sender: Any) {
self.performSegue(withIdentifier: Constants.Segues.toFriends, sender: self)
}
#IBAction func profileNavTapped(_ sender: Any) {
let nav = self.navigationController //grab an instance of the current navigationController
DispatchQueue.main.async { //make sure all UI updates are on the main thread.
nav?.view.layer.add(CATransition().segueFromLeft(), forKey: nil)
nav?.pushViewController(ProfileVC(), animated: false)
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.setNavigationBarHidden(true, animated: true)
self.backgroundImageView.contentMode = UIView.ContentMode.scaleAspectFill
doNotDisturbLabel.isHidden = true
if !userName.isEmpty {
welcomeLabel.text = "Welcome Back, " + userName + "!"
} else {
welcomeLabel.text = ""
}
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .darkContent
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let friendsVC = segue.destination as? FriendsVC else {
return
}
FirestoreService.db.collection(Constants.Firestore.Collections.users).document(User.current.uid).getDocument { (snapshot, err) in
if let err = err {
print(err.localizedDescription)
} else {
let data = snapshot!.data()!
let requests = data[Constants.Firestore.Keys.requests] as? [String]
if let requests = requests {
friendsVC.requests = requests
}
}
}
}
class FriendsVC: UIViewController {
//var friends: [Friend] = User.current.friends
var friends: [User] = []
var requests: [String]?
#IBOutlet weak var requestsNumberLabel: UILabel!
#IBOutlet weak var backgroundImageView: UIImageView!
#IBOutlet weak var friendRequestsButton: UIButton!
#IBOutlet weak var homeNavButton: UIButton!
#IBOutlet weak var friendsTitle: UILabel!
#IBOutlet weak var friendTableView: UITableView!
#IBOutlet weak var addFriendButton: UIButton!
#IBOutlet weak var tableViewTopConstraint: NSLayoutConstraint!
#IBAction func friendRequestsTapped(_ sender: Any) {
self.performSegue(withIdentifier: Constants.Segues.toRequests, sender: self)
}
#IBAction func homeNavTapped(_ sender: Any) {
let nav = self.navigationController //grab an instance of the current navigationController
DispatchQueue.main.async { //make sure all UI updates are on the main thread.
nav?.view.layer.add(CATransition().segueFromLeft(), forKey: nil)
nav?.pushViewController(HomeVC(), animated: false)
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.setNavigationBarHidden(true, animated: true)
backgroundImageView.contentMode = UIView.ContentMode.scaleAspectFill
friendTableView.backgroundView?.backgroundColor = .white
friendsTitle.isHidden = false
UserService.getUserArray(uids: User.current.friendUids, completion: { (users) in
guard let users = users else {
print("User has no friends")
return
}
self.friends = users
self.friendTableView.reloadData()
})
guard let requests = self.requests else {
friendRequestsButton.isHidden = true
requestsNumberLabel.isHidden = true
self.tableViewTopConstraint.constant = 0
return
}
requestsNumberLabel.text = requests.count.description
// Do any additional setup after loading the view.
friendTableView.delegate = self
friendTableView.dataSource = self
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let homeVC = segue.destination as? HomeVC {
homeVC.userName = User.current.firstName
} else if let requestsVC = segue.destination as? RequestsVC {
UserService.getUserArray(uids: self.requests!) { (requesters) in
if let requesters = requesters {
requestsVC.requesters = requesters
}
}
}
}
}
When my app loads into the home screen, there is no problem, and when a button is tapped to transition to FriendsVC, there is no problem. However, when I try to initiate the transition from HomeVC to ProfileVC or from FriendVC to HomeVC, I get the error: "Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value" at the self.backgroundImageView.contentMode = UIView.ContentMode.scaleAspectFill lines in my viewDidLoad methods. These segues have something in common in that these are the ones where I override the prepare() function, but I'm not sure what I'm doing wrong

View Controller doesn't find a func member

I'm getting this error:
Value of type 'DiscountVC' has no member 'calculateTotal'. And I have no clue why. Basically, I'm trying to make this calculator:
It should work as soon as you insert any value on the discountTF. Also, I have some pre-discounted buttons that just edit the discount value. The subtotalLabel value comes from another ViewController. For testing purposes, I'm using an initial value of 999.9.
import UIKit
class DiscountVC: UIViewController {
#IBOutlet var numericKeyboardView: UIView!
#IBOutlet var subtotalLabel: UILabel!
#IBOutlet var discountTF: UITextField!
#IBOutlet var totalLabel: UILabel!
var subtotal : Double = 999.9
var discount : Double = 0.0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
addKeyboard(view: numericKeyboardView)
subtotal = 999.9
discount = 0.0
discountTF.addTarget(self, action: #selector(self.calculateTotal(_:)), for: UIControl.Event.editingChanged)
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
func calculateTotal() {
let totalDouble = Double(subtotal) - Double(discountTF.text!)!
totalLabel.text = String(totalDouble)
}
func addKeyboard(view: UIView) {
let numericKeyboard = KeyboardVC(nibName: "NumericKeyboardVC", bundle: nil)
view.addSubview(numericKeyboard.view)
addChild(numericKeyboard)
}
#IBAction func fivePercentedButtonPressed(_ sender: Any) {
discount = Double(discountTF.text!)! * 0.05
discountTF.text = "\(discount)"
print(discount)
}
#IBAction func tenPercentButtonPressed(_ sender: Any) {
discount = Double(discountTF.text!)! * 0.1
discountTF.text = "\(discount)"
print(discount)
}
#IBAction func fifteenPercentButtonPressed(_ sender: Any) {
discount = Double(discountTF.text!)! * 0.15
discountTF.text = "\(discount)"
print(discount)
}
#IBAction func twentyPercentButtonPressed(_ sender: Any) {
discount = Double(discountTF.text!)! * 0.2
discountTF.text = "\(discount)"
print(discount)
}
#IBAction func goButton(_ sender: Any) {
}
}
Change to
#objc func calculateTotal(_ tex:UITextField){ --- }

Bug Problems With Swift and XCode

Help, I am coding this game, and I keep getting an error that says:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
Example:
Everything has worked normally until I added code for the trump coin image and the label that says 'Score:'
import UIKit
class ViewController: UIViewController {
//DEFINING VARIABLES
var gameIsRunning = false
var paused = false
var totalCoins = 0
var totalScore = 0
var gameCoins = 0
var gameScore = 0
#IBOutlet var titleCoinsLabel: UILabel!
#IBOutlet var titleScoreLabel: UILabel!
#IBOutlet var titleTrumpCoin: UIImageView!
#IBOutlet var titleScoreRun: UILabel!
#IBOutlet var gameTitle: UILabel!
#IBOutlet var playButton: UIButton!
#IBOutlet var pauseButton: UIButton!
#IBOutlet var pauseView: UIView!
#IBOutlet var resumeButton: UIButton!
#IBOutlet var optionsButton: UIButton!
#IBOutlet var tutorialButton: UIButton!
#IBOutlet var rateApp: UIButton!
#IBOutlet var quitButton: UIButton!
#IBOutlet var tutorialBackButton: UIButton!
#IBOutlet var tutorialView: UIView!
#IBOutlet var titleOptions: UIButton!
#IBOutlet var titleTutorial: UIButton!
#IBOutlet var optionsView: UIView!
#IBOutlet var optionsBack: UIButton!
//WHEN GAME LOADS WHAT TO DO
override func viewDidLoad() {
super.viewDidLoad()
gameIsRunning = false
pauseButton.isHidden = true
pauseButton.isEnabled = false
pauseButton.layer.cornerRadius = 10
pauseButton.alpha = 0.75
pauseView.isHidden = true
pauseView.layer.cornerRadius = 20
tutorialView.isHidden = true
resumeButton.layer.cornerRadius = 8
optionsButton.layer.cornerRadius = 8
tutorialButton.layer.cornerRadius = 8
rateApp.layer.cornerRadius = 8
quitButton.layer.cornerRadius = 8
tutorialBackButton.layer.cornerRadius = 8
optionsView.layer.cornerRadius = 20
optionsBack.layer.cornerRadius = 8
optionsView.isHidden = true
titleCoinsLabel.text = String(totalCoins)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//STARTING GAME
#IBAction func startGame(_ sender: AnyObject) {
if gameIsRunning == false {
gameIsRunning = true
titleCoinsLabel.isHidden = true
titleScoreLabel.isHidden = true
playButton.isHidden = true
playButton.isEnabled = false
gameTitle.isHidden = true
gameTitle.isEnabled = false
pauseButton.isHidden = false
pauseButton.isEnabled = true
titleTutorial.isHidden = true
titleTutorial.isEnabled = false
titleOptions.isHidden = true
titleOptions.isEnabled = false
titleScoreRun.isHidden = true
titleTrumpCoin.isHidden = true
//NOT DEFINED YET
runGame()
}
}
//PAUSE
#IBAction func pauseGame(_ sender: AnyObject) {
paused = true
pauseView.isHidden = false
}
//RESUME
#IBAction func resumeGame(_ sender: AnyObject) {
paused = false
pauseView.isHidden = true
}
//VIEW OPTIONS
#IBAction func optionsView(_ sender: AnyObject) {
optionsView.isHidden = false
pauseView.isHidden = true
}
#IBAction func titleOptionsView(_ sender: AnyObject) {
optionsView.isHidden = false
}
//BACK FROM OPTIONS
#IBAction func optionsBack(_ sender: AnyObject) {
optionsView.isHidden = true
if (paused == true) {
pauseView.isHidden = false
} else {
pauseView.isHidden = true
}
}
//OPTIONS TWEAKS
#IBAction func gameVolumeSlider(_ sender: AnyObject) {
}
#IBAction func musicVolumeSlider(_ sender: AnyObject) {
}
//VIEW TUTORIAL
#IBAction func tutorialView(_ sender: AnyObject) {
pauseView.isHidden = true
tutorialView.isHidden = false
}
#IBAction func titleTutorial(_ sender: AnyObject) {
tutorialView.isHidden = false
}
//BACK FROM TUTORIAL
#IBAction func backTutorial(_ sender: AnyObject) {
tutorialView.isHidden = true
if (paused == true) {
pauseView.isHidden = false
} else {
pauseView.isHidden = true
}
}
//RATE APP
#IBAction func rateApp(_ sender: AnyObject) {
}
//QUIT GAME
#IBAction func quitGame(_ sender: AnyObject) {
titleScoreLabel.isHidden = false
titleCoinsLabel.isHidden = false
pauseButton.isHidden = true
pauseView.isHidden = true
gameTitle.isHidden = false
gameTitle.isEnabled = true
playButton.isHidden = false
playButton.isEnabled = true
titleTutorial.isHidden = false
titleTutorial.isEnabled = true
titleOptions.isHidden = false
titleOptions.isEnabled = true
titleScoreRun.isHidden = true
titleScoreRun.isHidden = false
titleTrumpCoin.isHidden = false
titleScoreLabel.text = String(gameScore)
titleCoinsLabel.text = String(totalCoins)
totalScore = totalScore + gameScore
gameScore = 0
totalCoins = totalCoins + gameCoins
gameCoins = 0
}
//RECOGNIZING SWIPES
#IBAction func swipeRight(_ sender: AnyObject) {
if (gameIsRunning == true) {
}
}
#IBAction func swipeLeft(_ sender: AnyObject) {
if (gameIsRunning == true) {
}
}
#IBAction func press(_ sender: AnyObject) {
}
//FUNCTIONS TO RUN GAME
func runGame() {
}
}
It would appear that you have not hooked up the titleScoreLabel outlet correctly. Double check that in Interface Builder.