Post

Replies

Boosts

Views

Activity

Reply to Why is this crashing?
Thank you for the help with streamlining it. I couldn't figure that out earlier. As for where it crashes, it prints it fine and then crashes at cell.textLabel?.text = unlocked[indexPath.row], if I comment that out it crashes when setting the image.
May ’21
Reply to Why is this crashing?
Could you please give me an example? This is what is not running:                         if IconChange.setIconPurchased == true {                             print("purchased = true")                             self.iconSelected = self.names[indexPath.row]                             UserDefaults.standard.setValue(self.names[indexPath.row], forKey: "iconSelected")                             self.IconSelector.reloadData()                             tableView.cellForRow(at: indexPath)?.accessoryType = .checkmark                             IconChange.pushBack = true                             self.navigationController?.popViewController(animated: true) Also, I am mysteriously getting the index out of range error and crashing again.
May ’21
Reply to Run something before another thing
Yes here you go: ViewDidLoad and ViewWillApear - https://developer.apple.com/forums/content/attachment/19f24097-1ab4-4f78-bebb-9ea56f120ef4 Also, I read up on breakpoints. However, I have not had the time to figure out what's wrong using breakpoints. Let me know if you want my full project.
Mar ’21
Reply to Run something before another thing
Here you go:     override func viewDidLoad() {         super.viewDidLoad()         // Do any additional setup after loading the view.         if NetworkMonitor.shared.isConnected {             Utilities.checkads(bannerView: bannerView, bannerViewHeight: bannerViewHeight)             checkAppVersion()             setRandomJoke()             DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {                // Code you want to be delayed                 self.setRandomJoke()                 self.checkRandomJokeFail()             }         }else {             randomJoke.text = "Random Joke: Failed to connect to server"             adLoadError.text = "Error Loading Ad"             Utilities.checkToHideAds(bannerViewHeight: bannerViewHeight)         }         Utilities.styleFilledButton(changeJoke)         recentCat.delegate = self         recentCat.dataSource = self         checkRecentCat()         if Utilities.openNum == 1 {             Welcome.text = "Welcome! Check out our app. In the categories section you will find all of our jokes!"         }         bannerView.rootViewController = self         bannerView.delegate = self         print("saveCat Defaults = \(Utilities.saveCat)")     }     override func viewWillAppear(_ animated: Bool) {         super.viewWillAppear(animated)         if NetworkMonitor.shared.isConnected {             print("connected to internet")             adLoadError.text = "Loading Ad"             Utilities.checkads(bannerView: bannerView, bannerViewHeight: bannerViewHeight)             bannerView.rootViewController = self             checkRecentCat()             recentCat.reloadData()             if randomJoke.text == "Random Joke: " || randomJoke.text == "Random Joke: Failed to connect to server" {                 setRandomJoke()                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {                    // Code you want to be delayed                     self.setRandomJoke()                     self.checkRandomJokeFail()                 }             }         }else {             print("not connected to internet")             adLoadError.text = "Error Loading Ad"         }         Utilities.checkToHideAds(bannerViewHeight: bannerViewHeight)     }     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {         let backItem = UIBarButtonItem()         backItem.title = "Back"         navigationItem.backBarButtonItem = backItem // This will show in the next view controller being pushed     }
Mar ’21