title: How to initialize a Dictionary with structure components in Swift
body: <p>I have the following structure:</p>
  
  <pre><code>struct song {
  var songnum: Int = 0
  var name = "not defined"
  var lyrics_wo_chords = NSMutableAttributedString()
  var lyrics_w_chords = NSMutableAttributedString()
  var favorite = false
  }
  </code></pre>
  
  <p>And I'm trying to make a dictionary <code>var songs = [String: [song]]()</code></p>
  
  <p>where the the <code>String</code> is the name of the Songbook and the <code>[song]</code>
  is an array of structures called song that hold the individual structure members</p>
  
  <p>I've tried this <code>songs["SongBook name"] = song.self as? [song]</code> to add a new Key to the Dictionary. But otherwise, i have no idea how i would initialize it.</p>
  
  <p>Also, when i append the array of the Key:</p>
  
  <pre><code>songs["SongBook name"]?.append(song(
  songnum: 1, 
  name: "Name", 
  lyrics_o_chords: NSMutableAttributedString(string:"No Chords"), 
  lyrics_w_chords: NSMutableAttributedString(string: "With Chords"), 
  favorite: 
  false))`             
  </code></pre>
  
  <p>the dictionary returned is nil</p>
  
  <p>Any help would be much appreciated, thank you</p>