Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS missing something to switches reference or something?

Tags:

ios

swift

So my app is a basic music library in which when a user clicks on the album, the view switches to a reference id and that id correlates with the album just giving it basic info like on the artist and songs and whatnot. Something is missing to the point when I run the app nothing is happening at all or the app crashes.

  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)


}
like image 905
Sonny Avatar asked May 05 '16 18:05

Sonny


1 Answers

you need to create an identities in the viewDidload and have those refernce in the viewcontroller. ex. Identities = ["a", "b"]

like image 109
SScoder93 Avatar answered Sep 30 '22 11:09

SScoder93