In collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath method i m trying to load array of audio files into collection view cells but based on indexPath row it is skipping cell at index 0 and from cell at index 1 it is playing audio file when cell selected. i m unable to understand why.
Here is my code
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
audioArray =[[NSArray alloc] initWithObjects:@"0", @"1", @"2", @"3", nil];
NSString *filePath = [audioArray objectAtIndex:indexPath.row];
NSString *audioFilePath = [[NSBundle mainBundle] pathForResource:filePath ofType: @"mp3"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: audioFilePath];
audioPlayer = [[AVAudioPlayer alloc]
initWithContentsOfURL:fileURL error:nil];
}
If some one can point me in the right direction. I will appreciate.
Thanks for help.