Posts

Showing posts with the label failable initializer

Bob Lee Course Part 12 (consolidation of lectures 17-20)

Before I begin the much-needed consolidation blog, I feel the need to introduce something into my weekly repertoire. Each week, I am going to work on a specific Xcode project! the reason why is that Bob's course is totally separate to the main Xcode project stuff - it's all on playgrounds. That's fine as I am really learning the syntax but I am also losing touch with the practical element of getting code for a potential app together.  So this week I will focus on making a specific project. To start with, it will be a rework of something I have done before with Angela. I'm choosing her because her practical courses have been the most accessible and frankly the best. So after this consolidation entry, I will do an additional one to review what I have done since picking Swift back up in June - some 5 months ago. Also, for this entry, I'm adding in a ' MY TAKE' - so I can make it clearer what I know before revising any content. This is a good way of test...

Bob Lee Course Part 11 (lectures 19 to 20)

Image
Schoo inspection is over! This thankfully means that I will have more time to code in the coming weeks. Last time I focused on computed properties including get/set. Now not all of that worked before. Never mind. Anyway, we're starting now with 'property observers' - getSet and willSet. Let's go! Property Observers Start Time - 15:04 So that is the difference between willSet and didSet. Interesting. var myGrade: Int = 80 {     willSet {         print ( "Hey something happened!" )     }     didSet {         print ( "Hey something else happened!" )     } } myGrade = 100 Simple enough but once again my playground seems to be using the same error message of the code not compiling.... Paused at 15:09... Right I am doing the update on Xcode - we will see if that helps! It could be the mac needs an update too...Anyway, I'm going to crack on just by looking at...

*EXTRA ENTRY* Properties and Initializers - recap!

Technically, I promised not so many entries but I really feel the need to go over some of this! There was a lot of content in the last couple of sessions that I did not feel were clearly explained enough - no offence Pasan but they were hard to follow! So now is the time to seek out a bit more information. This is very 'casual' - I have an Avengers film on in the background and am not going under any time constraints or anything - I have plenty this evening. So I just want to clarify a few things and get some hands-on practice. Let's go! Properties From Pasan's explanations, there are several different types of these. This is what I know: Stored properties - these are values which are either declared within the class/struct/enum, or declared upon initialization.  Computed properties - these require a calculation and a reference to one of the stored properties, which may not yet have a value. The computed property can be accessed when an instance is create...