Posts

Showing posts with the label get set

Bob Lee Course Part 15 (Consolidation of Chapter 2 - lectures 16 to 25)

So, a great chance to make sense of all of the concepts in Chapter 2. I will then crack on with Chapter 3 tomorrow! Chapter 2 was all about Object Oriented Swift. A lot of the terminology was familiar but I do feel on the most part (other than singleton stuff...) that my understanding improved with all of this. So let's go over it now! Start Time - 12:03 Convenience Init My Take - this is very simply another way to initialize an object. It's called convenience because the block of code for that init method has it all going on, then the initialisation process is very simple, or convenient. It could be as simple as using () after the class name. Yep, got it! Here's my example from before: class  Human {      var  name:  String      init (name:  String ) {          self . name  = name     }           convenience   init () {     ...

Nick Walter Challenges (Part 5)

Image
Yes I managed to find time for one more session! So here we go - now going on to properties. The next several will be all linked to class aspects, so I'm actually going to go through them before the challenges. Always worth building my knowledge up on these as I need to! Start Time - 20:34 Computed Properties So from what I can remember about these, the property is not stored but requires some sort of computation. In the example below, I have two stored properties: class Dog {     var name = ""     var age = 0 } So this is a computed property - it requires the use of the stored property of age and creates a  temporary one of current year. Makes total sense.  var birthYear: Int {         let currentYear = 2018         return currentYear - age     } This looks like a function - using return and all. I could actually use a function but a computed property is bet...

Ray Wenderlich Course Part 11 (up to lesson 101)

Yes! Managing to get in a couple of consecutive days of entries. Now, it would be easy to be disheartened after the Collections lessons, which were all very tricky! However, the comments confirm that they were confusing - not just to me. So I am going to plough on and try to get Structures done relatively quickly so I can move on to Classes next, then will be able to start the next project! That's the intention anyway! I know that structures and classes bundle together information. They are similar however structures are used for values whereas classes are for objects. I also know that classes are a 'reference' type. These seem to be particularly important to make code more powerful and specific. Structures *This time I AM going to type and code along - it's the best way of getting something ingrained into your memory after all! AND I will use 'normal' speed. let restaurantLocation = ( 2 , 4 ) let restaurantRange = 2.5 // Pythagorean Theorem 📐...