IOS缺少切换参考或东西的东西?

Son*_*nny 6 ios swift

因此,我的应用程序是一个基本的音乐库,当用户点击相册时,视图会切换到参考ID,并且该ID与相册相关,只是给出基本信息,如艺术家和歌曲等等.当我运行应用程序时,根本没有发生任何事情或者应用程序崩溃.

  var names=[String]()
var identities = [String]()


var ButtonAudioPlayer = AVAudioPlayer()

override func viewDidLoad(){

    names = ["That's The Spirit", "Chocolate Starfish and the Hot Dog Flavored Water", "IOWA"]



}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int)-> Int{

    return names.count
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)-> UITableViewCell{
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell")
    cell?.textLabel!.text = names [indexPath.row]

    return cell!

}

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    let vcName = identities[indexPath.row]
    let viewController = storyboard?.instantiateViewControllerWithIdentifier(vcName)
    self.navigationController?.pushViewController(viewController!, animated: true)


}
Run Code Online (Sandbox Code Playgroud)

小智 2

您需要在 viewDidload 中创建一个身份,并在 viewcontroller 中引用这些身份。前任。身份= [“a”,“b”]