title: How to code initwithcoder in Swift?
body: <p>i'm newbie in swift adn i have problem with initwithcoder in swift.</p>
  
  <p>I have class UserItem, i need it to save user login.</p>
  
  <p>in objective c is like this</p>
  
  <pre><code> - (id)initWithCoder:(NSCoder *)decoder{
      if (self = [super init]){
          self.username = [decoder decodeObjectForKey:@"username"];
      }
      return self;
  }
  </code></pre>
  
  <p>and in swift i'm trying like this</p>
  
  <pre><code>override init() {
     super.init()
  }    
  
  required init(coder decoder: NSCoder!) {
  
     self.username = (decoder.decodeObjectForKey("username")?.stringValue)!
  
     super.init(coder: decoder)
  }
  </code></pre>
  
  <p>but if like above, i get error on code </p>
  
  <pre><code>super.init(coder: decoder)
  </code></pre>
  
  <p>error message is "extra argument 'coder' in call</p>
  
  <p>i can't figure out anymore, so i'm try this code,</p>
  
  <pre><code>convenience init(decoder: NSCoder) {
     self.init()
  
     self.username = (decoder.decodeObjectForKey("username")?.stringValue)!
  }
  </code></pre>
  
  <p>but, get error </p>
  
  <pre><code>.UserItem initWithCoder:]: unrecognized selector sent to instance 0x7fd4714ce010
  </code></pre>
  
  <p>what should i do? thanks before for your help.</p>