title: Adding Convenience Initializers in Swift Subclass
body: <p>As a learning exercise I am trying to implement a subclass of <code>SKShapeNode</code> that provides a new convenience initializer that takes a number and constructs a ShapeNode that is a square of number width and height.</p>
  
  <p>According to the <a href="https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html#//apple_ref/doc/uid/TP40014097-CH18-XID_284">Swift Book</a>:</p>
  
  <blockquote>
    <h3>Rule 1</h3>
    
    <p>If your subclass doesn’t define any designated initializers, it automatically inherits all of its superclass designated initializers.</p>
    
    <h3>Rule 2</h3>
    
    <p>If your subclass provides an implementation of all of its superclass designated initializers—either by inheriting them as per rule 1, or by providing a custom implementation as part of its definition—then it automatically inherits all of the superclass convenience initializers.”</p>
  </blockquote>
  
  <p>However, the following class doesn't work:</p>
  
  <pre><code>class MyShapeNode : SKShapeNode {
      convenience init(squareOfSize value: CGFloat) {
          self.init(rectOfSize: CGSizeMake(value, value))
      }
  }
  </code></pre>
  
  <p>Instead I get:</p>
  
  <pre><code>Playground execution failed: error: &lt;REPL&gt;:34:9: error: use of 'self' in delegating initializer before self.init is called
          self.init(rectOfSize: CGSizeMake(value, value))
      ^
  &lt;REPL&gt;:34:14: error: use of 'self' in delegating initializer before self.init is called
      self.init(rectOfSize: CGSizeMake(value, value))
           ^
  &lt;REPL&gt;:35:5: error: self.init isn't called on all paths in delegating initializer
  }
  </code></pre>
  
  <p>My understanding is that <code>MyShapeNode</code> should inherit all of <code>SKShapeNode</code>'s convenience initializers because I am not implementing any of my own designated initializers, and because my convenience initializer is calling <code>init(rectOfSize)</code>, another convenience initializer, this should work. What am I doing wrong?</p>