UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Project 2

Forums > 100 Days of Swift

On day 21, as a wrap up we are asked to try and show our score as well as the name of the country in the navigation bar. I have tried various methods but I havent found out how to do it, and I am also struggling with the second challenge, to track the questions that have been asked, I'm thinking maybe tracking how many times the askQuestion function has been called? I do not know how to do that.

3      

For the first one, just set the title property of your view controller. The navigation view controller will take care of showing it in the navigation bar.

As for the second one, you're right. You need to create a counter and increment it in the askQuestion() function.

5      

Yes, I know how to make the title show, like the name of the country but we are also meant to make our score show, meaning it'll be two titles, this is where I am confused.

Thank you

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

No. It's a single title. You just put the country name and the score in a string and set it as the title. That's all.

title = "\(countryName) - Score: \(score)"

4      

Ah right thank you my stupid mistake

I used / instead of \

3      

Did you find solution of other exercises ?

3      

Did you find solution of other exercises ?

3      

Yes I did, do you need help?

3      

Yes i do , i cant complete 2 and 3 exercises Can you help me with that ?

3      

My pleasure, so what have you tried as a way to note the amount of times the question function has been called? I'll give you a clue, create a variable first and set it to zero, and you would like to put this variable into a certain function, and increment this variable in this function. Can you guess the function?

As for the third one, you should be working with the else, in your buttonTapped function. When the score is wrong, and put what is asked.

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.