// // SecondViewController.swift // grandfatherrock // // Created by Micah Gomez on 4/15/20. // Copyright © 2020 Micah Gomez. All rights reserved. // import UIKit class SecondViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource { let defaults = UserDefaults.standard func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { return type.count } func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { return type[row] } func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { print(type[row]) print(row) defaults.set(type[row], forKey: "selectedTitle") defaults.set(row, forKey: "titleNo") GlobalVars.selectedGame = type[row] GlobalVars.selectedGameNo = row GlobalVars.titleName = type[row] musicHandler.updateMusic() nowPlaying.text = GlobalVars.titleName! + " - " + String(GlobalVars.hour) } func numberOfComponents(in pickerView: UIPickerView) -> Int { return 1 } var type = ["New Horizons","New Leaf","City Folk/Wild World", "Population: Growing"] @IBOutlet weak var pickerView: UIPickerView! @IBOutlet weak var nowPlaying: UILabel! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. pickerView.selectRow(2, inComponent: 0, animated: true) pickerView.dataSource = self pickerView.delegate = self nowPlaying.text = GlobalVars.titleName! + " - " + String(GlobalVars.hour) } @IBAction func visitWebsite(_ sender: Any) { if let url = URL(string: "https://micahpgomez.dev") { UIApplication.shared.open(url) } } }