title: NSOutlineViewDataSource and Swift
body: <p>I'm trying to implement a NSOutlineViewDataSource with Swift and when using Swift strings the app is simply crashing. When I change the array <code>people</code> to be of NSString it works fine.</p>
  
  <p>According to <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/WorkingWithCocoaDataTypes.html#//apple_ref/doc/uid/TP40014216-CH6-XID_42" rel="nofollow">Working with Cocoa Data Types</a> the string bridging should be automatic when you import Foundation.</p>
  
  <p>Here's the data source code:</p>
  
  <pre><code>import Cocoa
  import Foundation
  
  class ViewController: NSViewController, NSOutlineViewDataSource {
  
      let people: [String] = ["Mary", "John", "Paul"] // when using NSString it works fine
  
      func outlineView(outlineView: NSOutlineView, numberOfChildrenOfItem item: AnyObject?) -&gt; Int {
          return item == nil ? people.count : 0
      }
  
      func outlineView(outlineView: NSOutlineView, isItemExpandable item: AnyObject) -&gt; Bool {
          return false
      }
  
      func outlineView(outlineView: NSOutlineView, child index: Int, ofItem item: AnyObject?) -&gt; AnyObject {
          return people[index]
      }
  
      func outlineView(outlineView: NSOutlineView, objectValueForTableColumn tableColumn: NSTableColumn?, byItem item: AnyObject?) -&gt; AnyObject? {
          return item
      }
  }
  </code></pre>
  
  <p>Any idea why is this happening?</p>
  
  <p>Xcode Version 6.1 (6A1052d)</p>
  
  <p>Xcode project is hosted here: <a href="https://github.com/tanob/ExampleNSOutlineView" rel="nofollow">https://github.com/tanob/ExampleNSOutlineView</a></p>