Learn Courses My Dashboard

14 Day Beginner Challenge (SwiftUI)

Questions relevant to Lesson 8 Challenge (structures)

The assignment calls to create 4 Properties and " Make all 4 properties have the private access level"

What is the difference between a regular and a private variable?
What is the purpose of this and are there any other access levels? Where can I find documentation to sort them out?

I also copied on my playground the solution to that challenge as found in the documentation. But I am unable to find a way to see the result on either of the right sidebar or on the bottom section. There isn’t any output that I can see the concatenation of my private variables. I can’t find a way to create a print line to make it visible either. What am I doing wrong?

Thank you for your help!

Hi Jocelyn,

Welcome to the Code Crew community.

When you declare a variable or a constant as private it means that it is not accessible from outside of the class or struct that it is defined within.

The Swift Programming Language is available on Apple Books:

To see the struct function in operation you need to do something like this in playground:

let myCar = Car()
print(myCar.getDetails())

That creates an instance of Car as myCar so then to access the function within the struct you specify the instance and then using dot notation access the function getDetails

Thank you for your reply! But I actually figured it out when I looked at the lesson 9 video. Nearly all my questions were answered with that video. I figured that the challenge following lesson 8 should actually be moved to the end of lesson 9 to practice and review the new material. Putting it at the end of lesson 8 confuses the student who is asked to use concepts that has not been seen yet…
I just wanted to suggest this for as not to confuse and discourage other students to follow through. I think the lessons are very clear and quite well broken down for an easy understanding. It is the best class to learn Swift I’ve seen so far.

4 Likes

Thanks, Joshembro. I was struggling with this too!

Hi All/Chris,

I am on the 14 day beginner challenge. Currently on lesson 7 challenge.
Not sure if info to complete the challenge or if I coding is even right, any help will be appreciated.

thanks

So, … where exactly are you struggeling?

Hi,

Lesson 7 challenge; Challenge 2.

This is what I have done, just wondering if it makes any sense?


func printTotalWithTax(subtotal :Double = 0, b: Double) -> Double {
    
    return subtotal*b
}

let mySum = printTotalWithTax(subtotal: 100, b: 1.13)
print(mySum)

Thanks


func printTotalWithTax(subtotal :Double = 0, b: Double) -> Double {
    
    return subtotal*b
}

let mySum = printTotalWithTax(subtotal: 100, b: 1.13)
print(mySum)

hey can you help on lesson 7 please?

Im stuck on all the challenges, starting from 1

I have this…

import UIKit

func goodmorning() {

}

goodmorning()

also how did you paste you Xcode that way? im super new to coding. help plz!

Your Playground code should look something like this for that challenge

import UIKit

func goodMorning() {
    print("Good Morning")
}

goodMorning()

Inside the function is where you add the print command.

When pasting code in your post, to format the code nicely, place 3 back-ticks ``` on the line above your code and 3 back-ticks ``` on the line below your code. Like this:

```
Code goes here
```

The 3 back-ticks must be the ONLY characters on the line. The back-tick character is located on the same keyboard key as the tilde character ~ (which is located below the Esc key). You can also highlight an entire code block and click the </> button on the toolbar to wrap the block for you.

The back-tick characters are not visible in the final post. They are just formatting directives.

Do I always capitalize the second word? Also im putting the back-ticks ``` above and below. Is there something that suppose to happen? or do I copy and paste? And does it matter if an error pops up.

Thanks so much! I’m really trying here. I was confused when watching the video. I kept putting “myFunc”

The idea is to copy the code from the Xcode window and paste that in your post. Add the 3 back-ticks above and below and you should see the preview window on the right show you what it looks like with the formatting directive taking effect.

okay I have the back-ticks on Xcode but nothing is appearing on the right side. Im horrible learning this way and better when someone is w/ me showing it. I know its something I need to learn.


**func** goodmorning() {

print("goodmorning")

}

goodmorning()

I figured out!!!

Hahaha. Well done. Take it bit by bit and things will fall into place.

Awesome! thanks man. Yeah I’m slow at this but willing to learn! If I have any other questions, which I will, can I reach out to you or post it on the comm.?

Just post the question in a new thread in the forum which will get answered by one of the moderators or someone else. I’m here quite often so I will always answer where I can and where I know the answer.

Just make sure that the question is in the right category.

Sweet! Thanks. I basically need help in all of challenge 7.
The war game was pretty solid but this stuff in 7 is tough. I keep going back n forth on the vid. Wrote notes. Maybe I’m making it harder than it is.