Created
December 22, 2016 04:24
-
-
Save koalahamlet/2c9feb45c74632d03c2effce054f2ade to your computer and use it in GitHub Desktop.
non working tableview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
@IBOutlet var tableView: UITableView! | |
let cellIdentifier = "asdfasdfasdf" | |
class SoundByte { | |
let name: String | |
let internalName: String | |
init(mName:String, mInternalName : String) { | |
name = mName | |
internalName = mInternalName | |
} | |
} | |
let soundBytes = [SoundByte(mName: "thank you", mInternalName: "IB_jizomida")] | |
// "IB_jizomida","IB_ossuoshipshoe","IB_poogi_something","IB_shilliyagisamnidad"] | |
let soundBites = ["IB_awnyawng", "IB_jizomida","IB_ossuoshipshoe","IB_poogi_something","IB_shilliyagisamnidad"] | |
var audioPlayers = [AVAudioPlayer]() | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return soundBites.count | |
} | |
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
print("You selected cell #\(indexPath.row)!") | |
let player = audioPlayers[indexPath.row] | |
player.play() | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) | |
cell.textLabel?.text = soundBites[indexPath.row] | |
return cell | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment