title: Get class name in convenience init Swift 3
body: <p>I'm trying to implement my own version of <code>convenience init(context moc: NSManagedObjectContext)</code>, the new convenience initialiser on NSManagedObject in iOS 10. Reason being I need to make it compatible with iOS 9.</p>
  
  <p>I've come up with this:</p>
  
  <pre><code>convenience init(managedObjectContext moc: NSManagedObjectContext) {
      let name = "\(self)".components(separatedBy: ".").first ?? ""
  
      guard let entityDescription = NSEntityDescription.entity(forEntityName: name, in: moc) else {
          fatalError("Unable to create entity description with \(name)")
      }
  
      self.init(entity: entityDescription, insertInto: moc)
  }
  </code></pre>
  
  <p>but it doesn't work because of this error... </p>
  
  <blockquote>
    <p>'self' used before self.init call</p>
  </blockquote>
  
  <p>Does anyone know how to get around this error, or achieve the same result in another way. </p>