Posts

Showing posts with the label lazy stored properties

Ray Wenderlich Functions and Types Course - Part 8

Just a little entry to try and maintain some momentum! Going to the next section now. Let's go! Start Time - 20:47 Properties and Methods This is the new chapter! Stored Properties I remember these from before. This is where you have variables/constants within a type and have the values set or they are entered on init. Property Observers Only useful for variable properties. These are only accessible when changing a value but not on init. struct Wizard {          var firstName : String {         willSet {             print ( " \( firstName ) will be set to \(newValue) " )         }         didSet {             if firstName . contains ( " " ) {                 print ( "No spaces! \( firstName ) is not a first name. You need to change to \(oldValue) " )   ...

Stephen DeStefano Swift 5 Course - Part 4 (Lectures 12 to 16)

Image
Not going to go into rambling detail about how it's been a long time etc. End of term, start of holiday is always mental! I have missed my regular coding so am going to get some in today, then there will be more on Monday! I was working through Stephen's course, which was becoming pretty technical and challenging. Let's go! Start Time - 07:17 Stored Properties So these store constant/variable data. A key point here. Structs are value types - if you have a constant stored property, you cannot change the value. You can for classes as they are reference types. All that was pretty easy to be honest. Lazy Properties So I'm just trying to figure out the purpose of these! Stephen is quite rambling. OK so when the property is actually initialised, that's when the lazy stored property is accessed. It's about saving memory. So not created until it has actually been used. If it's computationally expensive - if it will end up slowing things down! Right...

Treehouse Intermediate Course Part 2 (properties)

So a decent start yesterday with the first Treehouse Intermediate course. Just to recap it was about properties - stored, computed and typed. I get the difference between these and am getting more used to the syntax of get/set. My concern with this Treehouse course is that there seem to be no practical Xcode projects. This isn't necessarily a bad thing; it could be useful to explore some key concepts at greater depth before I resume with a Udemy course - mostly likely Angela's.  Anyway, just to reiterate my plan - I am to cover approx 3 hours per week. Yesterday was around an hour so half an hour today maximum. Here we go! Reading Modes This is the code that Pasan has created which I've just copied and pasted: mport UIKit enum ReadingMode {     case day     case evening     case night          var statusBarStyle: UIStatusBarStyle {         switch self {     ...