Skip to content

Instantly share code, notes, and snippets.

@marinat
Created October 25, 2018 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marinat/593efde07475b9a071f86448f51d5c4e to your computer and use it in GitHub Desktop.
Save marinat/593efde07475b9a071f86448f51d5c4e to your computer and use it in GitHub Desktop.
songsService.callApiGetArtists(onSuccess: { (response) in
self.artists = response.getArtists()
self.tableView.reloadData()
}) { (error) in
self.handleError(error: error)
}
//=--------------------------
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (artistButton.isActive) {
return artists.count
} else {
return songs.count
}
}
//---------------
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (artistButton.isActive) {
let cell = tableView.dequeueReusableCell(withIdentifier: "ArtistCell")!
cell.textLabel?.text = presenter.searchArtists[indexPath.row].name
return cell
} else {
return createSongCell(song: presenter.songs[indexPath.row], lastRow: indexPath.row == songs.count-1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment