Ray Wenderlich Fundamentals Course - Part 5

OK last part! I'm going to complete this fundamentals course today! Also, Xcode looks like it's ready for the official update - so I won't need Beta anymore. Anyway, time to go for it.

Start Time - 20:44

Structures

Grouping sets of related data together.
Technically, all of the below are structs!
 


struct Student {
    
    let name: String
    let grade: Int
    let pet: String?
}


let bobStudent = Student(name: "Bob", grade: 33, pet: nil)

Most of this is recap so skimming through
*Technical glitch for 5 approx minutes. Wifi back on!

Mutating. I've made sense of this at last! If you do a function that alters one of the STORED PROPERTIES e.g. grade, then I have to use the mutating keyword. Cool. 

Value type. I could clone an instance. That new version is unique and does not affect the original. Class (reference types) do.. It's also got to be a var, to change any of the values. 

Challenge!

OK actually stuck! I need a method to return the highest grade of the students array...going to get some help...

Magical! It worked in the end. I needed an empty array to put the grades into first. That makes sense and is a top tip - always create a new array, if you need to get values from an object. Rest of challenge all good. 

Classes

Going to skim through more quickly as am pushed for time...
Honestly have not paid much attention. Some focus on creating a structure, then changing it to a class. SO will do the challenge!

Done! Easy!

A key point here is you DON'T use the mutating word for functions that change the stored properties in classes. OK, interesting.

Another thing is that you can create a constant of the instance, and still then make changes to it. You can't do that with value types. 

Right, done! Course complete! Before doing the next course with the FULL Xcode, I'll do a consolidation entry. A final point about style (linked to API) and also that there are future courses ready. Raywenderlich.com is definitely the place for relevant, up to date content. 

Finish Time - 21:27 (approx 40 minutes)




Comments

Popular posts from this blog

*Xcode Project Entry 2* F1 Quiz - part 1

Angela Yu Course Part 10 (up to lesson 112)

Angela Yu Xcode 12 Course - Part 7 (lectures 74 to 79)