title: Swift - A little confusion between Required Initializer vs. Delegating initializer
body: <p>I am having a bit of confusion between required and delegating initializers when it comes to Swift classes.</p>
  
  <p>As you can see below in my example code, NewDog can be initialized in 1 of 2 ways. As you can see, you can initialize by supplying just the age upon initialization, in which case, a default name will be assigned ("Buddy").</p>
  
  <p>What I don't understand yet is why the NewDog class needs the required keyword for an initializer, if that initializer is not even being used?? See.. var georgie is using the regular initializer (not the required one in NewDog) and it works just fine. </p>
  
  <p>So what is the point of it being required if it is... in fact.. NOT required? *If I take away that initializer the compiler yells at me saying "required' initializer 'init' must be provided by subclass of 'Dog'".</p>
  
  <p>Well okay... I put it back in.. but yet I don't have to even use it, because the first initializer in NewDog is fulfilling all of the member property initializations... I do not see the logic here.</p>
  
  <pre><code>class Dog {
      var name : String
      required init(_ name: String) {
          self.name = name
      }
  }
  
  class NewDog: Dog {
      var age : Int?
      init(age: Int, name: String) {
          super.init(name)
          self.age = age
      }
  
      required init(_ name: String) {
          super.init(name)
      }
  }
  
  var georgie = NewDog(age: 6, name: "Georgie")
  georgie.age
  </code></pre>
  
  <p>So can someone explain to me what the required keyword is for? My guess it that it is just to tell the compiler "hey... calm down... the name property WILL be initialized in our subclass because you are yelling at me to require it... so just chill out and I will handle it on my own. I'm going to do it in an explicit subclass initializer that I am creating myself"...</p>
  
  <p>*****ALSO! Bonus question: Which one of the initializers in NewDog is the Designated Initializer?? </p>
  
  <p>Thanks</p>