I have been trying to develop full featured music application in Swift.I was trying to check out available open source music app written in swift.I found an useful music application(ESTMusicPlayer) but this application is written in objective-C.
I have almost replaced Objective-C version of MusicListViewContorller.h and MusicListViewContorller.m file with MusicListViewContorller.swift using Swift Interpolablity and Mix-Match features.
I have converted Objective-C version:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (_delegate && [_delegate respondsToSelector:@selector(playMusicWithSpecialIndex:)]) {
[_delegate playMusicWithSpecialIndex:indexPath.row];
} else {
MusicViewController *musicVC = [MusicViewController sharedInstance];
musicVC.musicTitle = self.navigationItem.title;
musicVC.musicEntities = _musicEntities;
musicVC.specialIndex = indexPath.row;
musicVC.delegate = self;
[self presentToMusicViewWithMusicVC:musicVC];
}
[self updatePlaybackIndicatorWithIndexPath:indexPath];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
To:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
delegate?.playMusicSpecial(indexPath.row)
self.updatePlayBackIndicatorWithIndexPath(indexPath)
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
What will be equivalent Piece of codes for the following codes in Swift?
if (_delegate && [_delegate respondsToSelector:@selector(playMusicWithSpecialIndex:)]) { [_delegate playMusicWithSpecialIndex:indexPath.row]; }
What is alternative code for
respondToSelector:
in swift ?