Search code examples
swiftnsarrayswift3

Swift 3.0 NSArray valueForKey


In Swift 2.3 I've used this code, but after updating Swift to version 3.0 my code can't compile. Thank you!

var waterfallLibrary: NSArray = []
cell!.textLabel?.text = String(self.waterfallLibrary.valueForKey("songName").objectAtIndex(indexPath.row))

Solution

  • My problem solved with this code

    (waterfallLibrary.value(forKey: "songName") as! NSArray).object(at: indexPath.row)
    

    Thank you Leo Dabus!