Posts

Showing posts with the label super class

Bob Lee Course Part 4 (lesson 7)

Image
Back with Bob! Error Handling makes a lot more sense to me now. In my mind, you have if/let, guard/let and the ?? options to see if optionals have a value. Also, you can build in specific error handling options with a enum with messages, which follow the Error protocol. Then the do/try/catch block of code is used to test for errors. Error handling can also be built in to functions, to test for an error and also in classes within the initialisation. Like I said, I know a lot more this time round when I did EH with Treehouse! Right let's go! Start time - 12:20 Type Casting It's useful to start with the 'problem' Bob describes, to give this some sort of focus - So the keyword 'as' I've used before, but I can't remember how! Here's an example with 'as' let label = UILabel () as UIView class Human {          func introduce() {         print ( "I am a human" )     } } class Korean: Human ...

Ray Wenderlich Course Part 12 (up to lesson 110)

Here we go - the last of the 'theoretical' Ray sections of lessons before the next project. I'm not expecting to get all of this, after how tricky the last couple of sections have been. Again, I will type along where I can and keep it at normal speed.  Classes vs Structures So here is a simple structure (already typed out for me): struct PersonStruct {   var firstName: String   var lastName: String   var fullName: String {     return " \ ( firstName ) \ ( lastName )"   } } To make a class, it is simple enough. Same as above.  class P ersonClass {     var firstName: String     var lastName: String          var fullName: String {         return " \ ( firstName ) \ ( lastName )"     } } The difference of course is that inits are needed. I know all about this from before.  Ray mentions Heap vs Stack vi...