I fixed it again by instead of using num unlocked using unlocked.count and locked.count.
Post
Replies
Boosts
Views
Activity
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.
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.
I got it working, but now if IconChange.setIconPurchased == true isn't getting triggered because it is running before it's true. Ideas?
Alright. Thx
Hi,
I have determined that for whatever reason. The completion handler isn't being called. Ideas? Would you like to download a copy of my project?
Sorry and thank you
I have written the majority of my code. I am 13 and I want you to understand that I am still really learning. I will let you know when I have looked through and corrected stuff. That will probably be some time on Thursday.
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.
Here you go:
Full Code - https://developer.apple.com/forums/content/attachment/894f8e48-e35b-4ee0-937b-438560656346
Also I have accidentally activated and had to remove a breakpoint before. However, I don't know what they do or how to use them.
I don't know what you mean, would you like to see my code?
Full Code - https://developer.apple.com/forums/content/attachment/c8f8c003-1ee2-4873-bcf5-5e68750785d4
Thank you! However, now the jokes just will not load. Do you have an idea why?
I also decided to take out the auto counting.
Thank you so much!
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
}
What will 120 do? Also, I figured out what you were saying and here is the function header:
func setRandomJoke() {