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)
}
you need to create an identities in the viewDidload and have those refernce in the viewcontroller. ex. Identities = ["a", "b"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With